Awkward Number

View as PDF

Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

We define an "Awkward Number" a number that meets the following requirement:

The number must have each of the digits 9, 4, and 1 appear at least once, and there may be no other digits that exist.

Given N, Andrew wants you to calculate the number of Awkward Number's that appear from 1 to N.

Input Specification

The first and only line of input will contain an integer N, such that 1 \le N \le 10^9.

Output Specification

The output will contain a single integer, the number of Awkward Number's that exist from 1 to N, inclusive.

Sample Input 1

1000

Sample Output 1

6

Sample Explanation

For the first sample, the 6 Awkward Numbers are 149, 194, 419, 491, 914, and 941.


Comments

There are no comments at the moment.