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.