#P265. 练43.3算进制

练43.3算进制

Description

A number system is a method of counting with carry. We commonly use the decimal system, which carries over when reaching ten. A base-KK system carries over when reaching KK. In a base-KK system, each digit position can only contain numbers from 00 to K1K-1. For example, binary only uses 00 and 11, ternary uses 00, 11, and 22, and decimal uses 00 through 99.
For bases greater than 10, we use letters to represent digits: AA represents 10, BB represents 11, CC represents 12, and so on.
Given a positive integer in string form, determine the minimum base in which this number can appear.

Input Format

A single line containing a string of length not exceeding 10510^5, consisting only of digits and uppercase letters, with no leading zeros.

Output Format

A single line containing an integer representing the minimum base in which this number can appear.

Sample

31
4