101862: [AtCoder]ABC186 C - Unlucky 7

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

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)?

Constraints

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

Input

Input is given from Standard Input in the following format:

$N$

Output

Print an integer representing the answer.


Sample Input 1

20

Sample Output 1

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 Input 2

100000

Sample Output 2

30555

Input

题意翻译

给定一个正整数 $n$,求出 $1$ 至 $n$ 中有多少个数满足:该数在十进制下和八进制表示下均不含 $7$。 $1 \leq n \leq 10^5$。

加入题单

算法标签: