100 #ABC186C. [ABC186C] Unlucky 7

[ABC186C] Unlucky 7

Score : 300300 points

Problem Statement

Takahashi hates the number 77.

We are interested in integers without the digit 77 in both decimal and octal. How many such integers are there between 11 and NN (inclusive)?

Constraints

  • 1N1051 \leq N \leq 10^5
  • NN is an integer.

Input

Input is given from Standard Input in the following format:

NN

Output

Print an integer representing the answer.

20
17

Among the integers between 11 and 2020, 77 and 1717 contain the digit 77 in decimal. Additionally, 77 and 1515 contain the digit 77 in octal.

Thus, the 1717 integers other than 77, 1515, and 1717 meet the requirement.

100000
30555