eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Palindometer

Palindometer

While driving the other day, John looked down at his odometer, and it read \textbf{100000}. John was pretty excited about that. But, just one mile further, the odometer read \textbf{100001}, and John was REALLY excited! You see, John loves palindromes --- things that read the same way forwards and backwards. So, given any odometer reading, what is the least number of miles John must drive before the odometer reading is a palindrome? For John, every odometer digit counts. If the odometer reading was \textbf{000121}, he wouldn’t consider that a palindrome. \InputFile There will be several test cases in the data file, each consisting of an odometer reading on its own line. Each odometer reading will be from \textbf{2} to \textbf{9} digits long. The odometer in question has the number of digits given in the input - so, if the input is \textbf{00456}, the odometer has \textbf{5} digits. There will be no spaces in the input, and no blank lines between input sets. The data file will end with a line with a single \textbf{0}. \OutputFile For each test case, output the minimum number of miles John must drive before the odometer reading is a palindrome. This may be \textbf{0} if the number is already a palindrome. Output each integer on its own line.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
100000
100001
000121
00456
0
Вихідні дані #1
1
0
979
44