1400 -- Interesting Number
Time Limit :1000 MS Memory Limit :65536 KB
Accepts : 165 Submits : 282
User Accepts : 139 User Submits : 154
<Submit>   <Statistics>   <Discuss>

Description

N(100<=N<=999) is a positive integer,so N = a1*100+a2*10+a3. If a1*a2*a3 equals to a1+a2+a3, then we can say that N is an interesting number. For any integer MAX which is given, alpc46 want to know how many numbers that are interesting numbers that no more than MAX.
 

Input

There are several test cases, and each line one integer, the MAX(100<=MAX<=999). A value of 0 for MAX signals the end of the input.

Output

For each input set, output one line contains exactly one integer , which tells how many interesting numbers that no more than MAX.

Sample Input

100
125
0

Sample Output

0
1

Source

Alpc College 9 Contest 2009
<Submit>   <Statistics>   <Discuss>
 


Powered by Zhang Zhaoning PDL College of Computer
Since 2006.03.09 | 2007.11.22 | 2010.03.02 Copyright (r) 2006 - 2010 All Rights Reserved