favorite We need a little bit of your help to keep things running, click on this banner to learn more

Nikifor 2

Nikifor 2

Nikifor has a number x. He doesn't need it. He needs a number y. Nikifor tries to obtain the required number by erasing some digits from x. But he is not lucky in the meanwhile. May be he is to choose an appropriate number system?

Write a program that reads two natural numbers x and y, and determines a minimal radix of a number system that it is possible to obtain in it the number y from xby erasing some digits. If it is impossible, your program should write to an output a message "No solution".


The only line of an input contains two numbers x and y (1y < x1 000 000), separated with a space.


The only line of an output contains either the message "No solution", if there is no appropriate number system or a natural number, not less than 2, that is an answer in the problem.

Time limit 1 second
Memory limit 64 MiB
Input example #1
127 16
Output example #1
Author Дмитрий Филимоненков
Source Ural State Univerisity Personal Contest Online February