5.2 Dexter and D-numbers

Score: 60pts

Time Limit: 1.00 sec

Dexter in his laboratory was working on new numbers which he would call D-Numbers. D-number is a number which consists of only 1s and 2s. For eg - 1, 2, 12, 21 are D-numbers however 101, 72, 128 are not.

One fine day, DeDe walked into Dexter's lab and gave him a D-number \(X\) and asked him how many D-numbers exist which are smaller than the number \(X\). Can you help Dexter answer this question?

One fine day, DeDe walked into Dexter's lab and gave him a D-number \(X\) and asked him how many D-numbers exist which are smaller than the number \(X\). Can you help Dexter answer this question?

Constraints

\(1 \leq X \leq 10^9\)

Input Format

\(X\)

Output Format

\(N\)

\(N\) is the count of D-numbers smaller than X.

\(N\) is the count of D-numbers smaller than X.

Example 1

Input:

1

Output:

0

Explanation:

There is no D-number which is smaller than 1.

1

Output:

0

Explanation:

There is no D-number which is smaller than 1.

Example 2

Input:

22

Output:

5

Explanation:

The 5 D-numbers smaller than 22 are - 1, 2, 11, 12, 21.

22

Output:

5

Explanation:

The 5 D-numbers smaller than 22 are - 1, 2, 11, 12, 21.