eolymp
bolt
Try our new interface for solving problems
Problems

The Expression from the Numbers

The Expression from the Numbers

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

It can be done such as (2 + 2 * 2) + 2 / 2, or as 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.

Input

The natural numbers n and d are given in the one line (1n7, 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 times the number d.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 2
Output example #1
4