How do you see programming? Many people assume that the programmer has to work not only with programs, but also with different technologys. Artyom was also unlucky – his chief thinks the same way. The poor programmer was given an engineering calculator, a display, which contains $$$n$$$ digits. The calculator, of course, has only one working button – "increase the number on the screen by one".
Initially, the display shows the number $$$1$$$. Artyom needs the number $$$x$$$ on the calculator display, that satisfies the following conditions:
$$$1)$$$ $$$x$$$ is a power of $$$2$$$.
$$$2)$$$ The $$$k$$$–th number position of the number $$$x$$$ contains the digit $$$p$$$. (the digits of the calculator are numbered from right to left)
$$$3)$$$ Due to the fact that the display of the calculator can accommodate no more than $$$n$$$ digits, the number $$$x$$$ should also be no more than $$$n$$$ numbers positions.
Artyom afraids that the last button on his calculator will break soon, so he wants to use it as few times as possible, but at the same time try to find a number for the authorities. Help Artyom find out how many times he will have to press the calculator button to get the right number of $$$x$$$ on the display.
A single line of input contains natural numbers $$$n$$$, $$$k$$$ and $$$p$$$ ($$$1 \le n \le 18$$$, $$$0 \le k \lt n$$$, $$$0 \le p \le 9$$$) – the number of digits on the display of the calculator, the number of the discharge in which the digit $$$p$$$ should stand, and this digit itself.
Print a single number - the number of clicks on the calculator button. If the required number cannot be obtained on the calculator display, print "$$$-1$$$".
3 0 1
0
5 3 7
-1
5 2 0
1023
In the first example, the minimum number is $$$1$$$. It satisfies all conditions: $$$2^0=1$$$, in the zero digit of this number there is $$$1$$$ and in it only $$$1$$$ digit.
In the second example, there is no number satisfying the condition, so the answer is $$$-1$$$.
In the third example, the minimum suitable number is $$$2^{10}=1024$$$, therefore Artem needs to press the button 1023 times.