来源:https://codeforces.com/contest/49/problem/B
Sum
Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the positional notation wasn’t written anywhere. Now Vasya has to choose a base p and regard the expression as written in the base p positional notation. Vasya understood that he can get different results with different bases, and some bases are even invalid. For example, expression 78 + 87 in the base 16 positional notation is equal to FF16, in the base 15 positional notation it is equal to 11015, in the base 10 one — to 16510, in the base 9 one — to 1769, and in the base 8 or lesser-based positional notations the expression is invalid as all the numbers should be strictly less than the positional notation base. Vasya got interested in what is the length of the longest possible expression value. Help him to find this length.
The length of a number should be understood as the number of numeric characters in it. For example, the length of the longest answer for 78 + 87 = ? is 3. It is calculated like that in the base 15 (11015), base 10 (16510), base 9 (1769) positional notations, for example, and in some other ones.
Input
The first letter contains two space-separated numbers a and b (1 ≤ a, b ≤ 1000) which represent the given summands.
Output
Print a single number — the length of the longest answer.
Examples
input
Copy
78 87
output
Copy
3
input
Copy
1 1
output
Copy
2f
翻译:
瓦夏研究位置数字系统。不幸的是,他经常忘记写写表达式的符号基础。有一次,他在笔记本上看到一张纸条,上面写着a + b = ?,并且位置符号的基础没有写在任何地方。现在,Vasya 必须选择一个基数 p,并将表达式视为以 p 为基数的位置表示法编写的表达式。瓦夏明白,他可以用不同的碱基得到不同的结果,有些碱基甚至是无效的。例如,以 16 为基的位置表示法中的表达式 78 + 87 等于断续器16,在以 15 为底的位置表示法中,它等于11015,在基地 10 一 — 到36w10,在基地 9 一 — 到1769,而在以 8 为基数或更小基的位置表示法中,表达式无效,因为所有数字都应严格小于位置表示法基数。Vasya 对尽可能长表达式值的长度感兴趣。帮助他找到这个长度。
数字的长度应理解为其中的数字字符数。例如,78 + 87 = ? 的最长答案的长度为 3。它的计算方式与基数 15 (11015),基数 10 (36w10), 基地 9 (1769) 位置表示法,例如,在其他一些表示法中。
第一个字母包含两个空格分隔的数字 a 和 b(1 ≤ a、b ≤ 1000),它们表示给定的求和。
打印单个数字 — 最长答案的长度。