Telephone

Find the base between 2 and 10 whose representation of N has the fewest adjacent digit changes, breaking ties by the largest base.

Easy2MathImplementationBrute forceNo attempts yetTime limit1sMemory limit128 MB

Problem

Memorizing telephone numbers can be tiring. Sometimes it is easier to remember a number in some base other than decimal and convert it back to decimal only when it is needed.

The complexity of a number written in some base is the number of pairs of adjacent digits that differ. For example, the complexity of 123 is 2, and the complexity of 4444 is 0.

Given a number, find the base between 2 and 10 in which its representation has the smallest complexity.

Input

The only line contains a positive integer NN with at most ten decimal digits (1N99999999991 \le N \le 9\,999\,999\,999).

Output

Print one integer between 2 and 10: the base in which the representation of NN has the smallest complexity. If several bases achieve it, print the largest of them, since the representation in that base is probably the shortest.