시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 51 21 21 52.500%

문제

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

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

입력

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

출력

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

예제 입력 1

100000
100001
000121
00456
0

예제 출력 1

1
0
979
44

힌트

W3sicHJvYmxlbV9pZCI6IjQwOTYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMzBcdWI5YjBcdWI0ZGNcdWI4NWNcdWJiZjhcdWQxMzAiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YzJiOVx1ZDY1OFx1Yzc3NFx1YjI5NCBcdWQzMzBcdWI5YjBcdWI0ZGNcdWI4NmNcdWM3NDQgXHVjODhiXHVjNTQ0XHVkNTVjXHViMmU0LiBcdWM5YzBcdWFlMDggXHVjMmI5XHVkNjU4XHVjNzc0XHVjNzU4IFx1Yzc5MFx1YjNkOVx1Y2MyOFx1Yzc1OCBcdWM4ZmNcdWQ1ODkgXHVhYzcwXHViOWFjXHVhY2M0XHVjNWQwIDEwMDAwMFx1Yzc3NCBcdWM4MDFcdWQ2MDBcdWM3ODhcdWIyZTQuIFx1Y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