Problem F
Free Desserts

Quido has lunch in Hugo’s restaurant every day. He likes the
restaurant because all of its prices are expressed as integers,
and for each possible price (i.e. $
-
the bill is not identical to any of Quido’s previous bills,
-
the price of the beverage is less than the price of the main dish, and
-
the prices listed on the bill cannot mutually use the same digit. In essence, any digit which occurs in any of the entries (beverage, main dish, total) must be different from any of the digits of the other two entries.
Quido is on a budget and he pays the same price for his lunch every day. How many times can he have a free dessert?
Input
The input consists of a single line with one integer
representing the price
Output
Output the maximum number of times Quido can have a free
dessert at Hugo’s restaurant, provided that the price of his
lunch is always
If there are more than
Sample Input 1 | Sample Output 1 |
---|---|
37 |
4 8 29 9 28 11 26 15 22 |
Sample Input 2 | Sample Output 2 |
---|---|
30014 |
7 85 29929 88 29926 785 29229 788 29226 7785 22229 7788 22226 7789 22225 |
Sample Input 3 | Sample Output 3 |
---|---|
202020202020202058 |
3 7676767676767667 194343434343434391 37373737373737397 164646464646464661 67676767676767667 134343434343434391 |