#00036C

sumecif

We define a function f(n) as a sum of the digits of an integer n. From the interval [ A, B ] find a number k that occurs the most in the array: f(A), f(A + 1), f(A + 2), ..., f(B - 1), f(B). In the case there are multiple numbers that occur same number of times, find the largest one..



InputThe first line contains two integers A and B (1 <= A <= B <= 10.000.000).

OutputWrite the number k.

Input:
6 17
Output:
8
Explanation:
The values of f(x) for x = 6, 7, ..., 17 are 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8. The numbers 6, 7 and 8 occur twice..

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.