442. X + R(X) = N

Time limit per test: 0.75 second(s)
Memory limit: 262144 kilobytes
input: standard
output: standard



Ruslan is crazy about counting numbers and solving problems. His favourite pastime is to make up a problem and solve it by himself. Some time ago he heard about a very interesting problem: given the positive integer N, you have to say whether such X that X + R(X) = N exists or not, where X is a positive integer, and R(X) is the number X written backwards. Then, Ruslan has decided that this task is elementary, so he didn't start solving it, but made up a more difficult problem instead.

You are given the positive integer number N. How many positive integer numbers X are there, that X + R(X) = N?

R(X) is the number X written backwards. For example: $R(123) = 321$ $R(150) = 51$

Input
Input will consist of multiple test cases. Each case will be a single line containing number N (). A line with a single zero terminates the input.

Maximum size of input is bytes.

Output
Output for each test case should consist of a single integer on a line, indicating the number of numbers X satisfying the condition. Do not output leading zeros.

Example(s)
sample input
sample output
1
2
11
13
14003
767513456469789456166547987979741366664879441
0
0
1
1
0
60
0




Online Contester Team © 2002 - 2010. All rights reserved.