Problem Description
Gug likes palindromes, so he built an AI to tell if a number is a palindrome. When given a number N, she will say "N is almost a palindrome. It is only X away from the nearest palindrome."
Help Gug's AI find X, the distance to the nearest palindrome
A palindrome is a number that reads the same backward as forward, for example, 1234321, 0 and 10001 are palindromes, but 1112, 100, and 123211 is not. Numbers with leading 0s like 010 are not allowed.
The distance between 2 numbers a and b is defined as |a-b|.
Input
The input will consist of one line, the number N as defined above.
Output
The output should contain one line with the integer X as defined above.
Limits
Subtask 1(1%): 0 < N < 10
Subtask 2(17%): 0 < N < 106
Subtask 3(29%): 0 < N < 1012
Subtask 4(53%): 0 < N < 1018
Subtask 5(0%): Sample
Sample Input 1
12
Sample Output 1
1
Explanation
12 is 1 away from 11, a palindrome.
Sample Input 2
19
Sample Output 2
3
Explanation
19 is 3 away from 22, a palindrome.