Given a string of digits, define an operation to be incrementing some digit in the string. Increasing any digit that is not nine increases it by one. Increasing nine switches it to zero and also automatically increases the digit to its left, if any such digit exists, which may cascade and cause digits to its left to also be incremented, but these automatic increases are considered part of the original operation.
Given a string of digits, compute the minimum number of operations needed to make the string a palindrome.
Constraints
Input Specification
The input consists of a single line containing the string .
Output Specification
Print, on a single line, the minimum number of operations needed to make the string a palindrome.
Sample Input 1
0
Sample Output 1
0
Sample Input 2
009990001
Sample Output 2
3
Sample Input 3
9084194700940903797191718247801197019268
Sample Output 3
54
Comments