1830: Magical Source

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:12 解决:5

题目描述

Rick firmly believes that there are magical patterns related to some numbers. This belief is the result of his own tendency to find odd patterns everywhere. He has recently thought that some numbers have a "magical source". For example, the number 1371110974 has a magical source equal to 1234 because of the following process: 1234 + 12340 + 123400 + 1234000 + 12340000 + 123400000 + 1234000000 ------------ 1371110974 Formally, 1234 is a magical source of 1371110974 because there exists a number n such that the sum of a sequence of n numbers, where the i-th number (0-indexed) is 1234 multipled by 10^i, is equal to 1371110974. Note that by this definition, a positive number is a magical source of itself.

输入

Given a positive long x(x will be between 1 and 1000000000000 (10^12), inclusive.),return its minimum positive magical source.

输出

output the minimum positive magical source.

样例输入 复制

1371110974
111111
10989
120
109999999989

样例输出 复制

1234
1
99
120
99