eolymp
bolt
Try our new interface for solving problems
Problems

Nikifor 2

Nikifor 2

Nikifor has a number \textbf{x}. He doesn't need it. He needs a number \textbf{y}. Nikifor tries to obtain the required number by erasing some digits from \textbf{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 \textbf{x} and \textbf{y}, and determines a minimal radix of a number system that it is possible to obtain in it the number \textbf{y} from \textbf{x} by erasing some digits. If it is impossible, your program should write to an output a message "\textbf{No solution}". \InputFile The only line of an input contains two numbers \textbf{x} and \textbf{y} (\textbf{1} ≤ \textbf{y} < \textbf{x} ≤ \textbf{1 000 000}), separated with a space. \OutputFile The only line of an output contains either the message "\textbf{No solution}", if there is no appropriate number system or a natural number, not less than \textbf{2}, that is an answer in the problem.
Time limit 1 second
Memory limit 64 MiB
Input example #1
127 16
Output example #1
3
Author Дмитрий Филимоненков
Source Ural State Univerisity Personal Contest Online February