#abc301d. [abc301_d]Bitmask

[abc301_d]Bitmask

Problem Statement

You are given an integer NN and a string SS consisting of 0, 1, and ?. Let TT be the set of values that can be obtained by replacing each ? in SS with 0 or 1 and interpreting the result as a binary integer. For instance, if S=S= ?0?, we have $T=\\lbrace 000_{(2)},001_{(2)},100_{(2)},101_{(2)}\\rbrace=\\lbrace 0,1,4,5\\rbrace$.

Print (as a decimal integer) the greatest value in TT less than or equal to NN. If TT does not contain a value less than or equal to NN, print -1 instead.

Constraints

  • SS is a string consisting of 0, 1, and ?.
  • The length of SS is between 11 and 6060, inclusive.
  • 1leqNleq10181\\leq N \\leq 10^{18}
  • NN is an integer.

Input

The input is given from Standard Input in the following format:

SS NN

Output

Print the answer.


Sample Input 1

?0?
2

Sample Output 1

1

As shown in the problem statement, T=lbrace0,1,4,5rbraceT=\\lbrace 0,1,4,5\\rbrace. Among them, 00 and 11 are less than or equal to NN, so you should print the greatest of them, 11.


Sample Input 2

101
4

Sample Output 2

-1

We have T=lbrace5rbraceT=\\lbrace 5\\rbrace, which does not contain a value less than or equal to NN.


Sample Input 3

?0?
1000000000000000000

Sample Output 3

5