P28330 [洛谷] Middle School Math Problem
提高+
题目描述

Problem Background

Cirno: I know! The answer is -1 0, because Gensokyo doesn't have a teleporter!

Rumia: You're impossible... Forget it, let's try another middle school math problem.

Saying that, Rumia wrote down a sequence of numbers:

$1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , \cdots , 2048 , 4096 , 8192 , 16384 , \cdots$

Problem Description

Rumia: The general term formula for this sequence is $ x_n = 2^{n-1} $.

Now, you need to find out how many numbers in the first $ k+1 $ terms have 4 as their first digit (e.g., 4096).

The input is "encrypted."

See the Input Format section for detailed input method.

Input and Output Format

Input Format

A line containing two positive integers, $ t $ and $ k_0 $.

If $ t = 1 $, the actual $ k $ is $ k_0 $.

If $ t = 0 $, the actual $ k $ is $ 10^{k_0} $.

Output Format

An integer $ ans $, indicating how many numbers have 4 as their first digit.

Sample Input and Output

Sample Input #1

1 3

Sample Output #1

1

Sample Input #2

0 1

Sample Output #2

1

Sample Input #3

1 10

Sample Output #3

1

Notes

For 30% of the data, $k_0 \leq 10^7, t = 1$.

For 70% of the data, $k_0 \leq 10^9, t = 1$.

For another 30% of the data, $k_0 \leq 233, t = 0$.

For 100% of the data, $k_0 \geq 1$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 3
样例输出
1