Hide

Núll og tveir

/problems/iceland.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$, $2\, 002$, $0$ and $2$ are thus liked by both but $54$, $173$ and $120\, 120$ 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$ ($1 \leq n \leq 10^{50}$), 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

$n \leq 10^{3}$

2

15

$n \leq 10^{6}$

3

20

$n \leq 10^{18}$

4

25

$n = 10^{k}$, where $0 \leq k \leq 50$ ($n$ is of the form $100\dots $)

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
CPU Time limit 1 second
Memory limit 1024 MB
Languages English, Íslenska
Authors
Arnar Bjarni Arnarson and Bjarki Ágúst Guðmundsson
Source Forritunarkeppni Framhaldsskólanna 2020
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in