Problem6533--ABC186 —— C - Unlucky 7

6533: ABC186 —— C - Unlucky 7

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Takahashi hates the number $7$.
We are interested in integers without the digit $7$ in both decimal and octal. How many such integers are there between $1$ and $N$ (inclusive)?

Input

Input is given from Standard Input in the following format:
$N$

Output

Print an integer representing the answer.

Constraints

$1≤N≤10^5$
$N$ is an integer.

Sample 1 Input

20

Sample 1 Output

17

Among the integers between $1$ and $20$, $7$ and $17$ contain the digit $7$ in decimal. Additionally, $7$ and $15$ contain the digit $7$ in octal.

Thus, the $17$ integers other than $7$, $15$, and $17$ meet the requirement.

Sample 2 Input

100000

Sample 2 Output

30555

Source/Category

 AtCoder_ABC 100.186.ABC186