Hide

Problem C
Núll og tveir

Languages en is
/problems/nullogtveir/file/statement/en/img-0001.jpg
Image from flickr.com

Arnar and Arnar are looking at numbers together. Arnar only likes the digit 0 while Arnar only likes the digit 2. Since Arnar and Arnar are friends, they like numbers that have each others’ favorite digits. The numbers are however not allowed to contain any other digits.

The numbers 20, 2002, 0 and 2 are thus liked by both but 54, 173 and 120120 aren’t.

Now Arnar and Arnar have gathered all numbers from 0 to n, the highest number they know. They want to know how many numbers in their collection are liked by both of them, but they don’t know how to count. Can you help them with the counting?

Input

The first line of the input contains an integer n (1n1050), the highest number Arnar and Arnar know.

Output

Print how many numbers in the collection are liked by Arnar and Arnar.

Scoring

Group

Points

Constraints

1

10

n103

2

15

n106

3

20

n1018

4

25

n=10k, where 0k50 (n is of the form 100)

5

30

No further constraints

Sample Input 1 Sample Output 1
10
2
Sample Input 2 Sample Output 2
221
7
Sample Input 3 Sample Output 3
123456
32
Hide

Please log in to submit a solution to this problem

Log in