Time

13:03:25
23 May 2012
Version for print

The Expression from the Numbers

   This is enough known task from mathematics: how can you with help by 5 numbers of 2, signs of arithmetic actions and brackets to write down a number 7?

   It can be done such as (2+2*2)+2/2, so 22/2-2*2 or as 2*(2+2)–2/2.

   And you have to know what least natural number M can not be given such method, if you can use N numbers of the number D?

   Note: A division is executed entirely.


Specifications

   Input

   The natural numbers N and D are written down in the one line of file (1 ≤ N7, 1D9).

   Output

   You have to write the number M – the least number which can not be given as arithmetic expression if you can use N numbers of the number D.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 5.88235
Complexity: 57% 13/30

Example

Example input

3 2

Example output

4


← Industrious bees Problems The Way Home →