시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 95 47 43 53.750%

문제

승환이는 팰린드롬을 좋아한다. 지금 승환이의 자동차의 주행 거리계에 100000이 적혀있다. 승환이는 1km만 더 주행을 하면 100001이 된다! 승환이는 엄청나게 흥분했다.

주행 거리계에 적혀져 있는 수가 주어졌을 때, 몇 km를 더 주행하면 팰린드롬이 되는지 구하는 프로그램을 작성하시오. 승환이는 모든 자리가 팰린드롬이 되어야 한다. 따라서, 주행 거리계에 00121인 경우에는 팰린드롬이 아니다.

입력

입력은 여러 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, 현재 승환이의 주행 거리계에 적혀있는 수가 주어진다.이 숫자는 2자리와 9자리 사이(포함)이다. 예를 들어, 주행 거리계에 적히는 숫자의 갯수는, 입력으로 주어진 수의 숫자의 갯수와 같다. 그래서, 입력이 00456이라면, 5자리 숫자이다. 마지막 줄에는 0이 적혀있다.

출력

각 테스트 케이스에 대해서 주행 거리계의 수가 팰린드롬이 되기 위해 주행해야 하는 최소 거리를 출력한다. 만약 이미 팰린드롬이라면 0을 출력한다.

예제 입력 1

100000
100001
000121
00456
0

예제 출력 1

1
0
979
44
W3sicHJvYmxlbV9pZCI6IjQwOTYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMzBcdWI5YjBcdWI0ZGNcdWI4NWNcdWJiZjhcdWQxMzAiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzJiOVx1ZDY1OFx1Yzc3NFx1YjI5NCBcdWQzMzBcdWI5YjBcdWI0ZGNcdWI4NmNcdWM3NDQgXHVjODhiXHVjNTQ0XHVkNTVjXHViMmU0LiBcdWM5YzBcdWFlMDggXHVjMmI5XHVkNjU4XHVjNzc0XHVjNzU4IFx1Yzc5MFx1YjNkOVx1Y2MyOFx1Yzc1OCBcdWM4ZmNcdWQ1ODkgXHVhYzcwXHViOWFjXHVhY2M0XHVjNWQwIDEwMDAwMFx1Y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