実行時間制限: 2 sec / メモリ制限: 1024 MB
配点 : 300 点
問題文
高橋君は 7 が嫌いです。
1 以上 N 以下の整数のうち、10 進法で表しても 8 進法で表しても 7 を含まないような数はいくつありますか?
制約
- 1 \leq N \leq 10^5
- N は整数である。
入力
入力は以下の形式で標準入力から与えられる。
N
出力
答えを整数で出力せよ。
入力例 1
20
出力例 1
17
1 以上 20 以下の整数のうち、10 進法で表したときに 7 を含む数は 7,17、8 進法で表したときに 7 を含む数は 7,15 です。
よって、7,15,17 以外の 17 個の数が条件を満たします。
入力例 2
100000
出力例 2
30555
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