49B.md (1752B)
1 Source: https://codeforces.com/problemset/problem/49/B 2 3 B. Sum 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 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 *FF*16, 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. 22 23 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. 24 25 Input 26 27 The first letter contains two space-separated numbers *a* and *b* (1 ≤ *a*, *b* ≤ 1000) which represent the given summands. 28 29 Output 30 31 Print a single number — the length of the longest answer. 32 33 Examples 34 35 Input 36 37 ``` 38 78 87 39 ``` 40 41 Output 42 43 ``` 44 3 45 ``` 46 47 Input 48 49 ``` 50 1 1 51 ``` 52 53 Output 54 55 ``` 56 2 57 ```