atcoder#ARC127C. [ARC127C] Binary Strings

[ARC127C] Binary Strings

Score : 500500 points

Problem Statement

Snuke has written on a blackboard every integer from 11 through (2N1)(2^N-1), in binary.

Find the XX-th lexicographically smallest string when seeing the integers on the blackboard as strings.

Here, the input gives NN in decimal, but XX in binary.

Constraints

  • 1N1061 \leq N \leq 10^6
  • 1X2N11 \leq X \leq 2^N-1
  • XX is in binary.

Input

Input is given from Standard Input in the following format:

NN

XX

Output

Print the answer.

3
101
11

The strings written on the blackboard in lexicographical order are 1, 10, 100, 101, 11, 110, 111. Additionally, we have X=101(binary)=5(decimal)X=101(\mathrm{binary})=5(\mathrm{decimal}). Thus, the answer is 11.

10
10100011
1001001111
1000000
11111
1000000000000000000000000000000