eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

X + R(X) = N

X + R(X) = N

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 \textbf{N}, you have to say whether such \textbf{X} that \textbf{X + R(X) = N} exists or not, where \textbf{X} is a positive integer, and \textbf{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 \textbf{N}. How many positive integer numbers \textbf{X} are there, that \textbf{X + R(X) = N}? \textbf{R(X)} is the number \textbf{X} written backwards. For example: \textbf{$R(123) = 321$ $R(150) = 51$}. \InputFile Input will consist of multiple test cases. Each case will be a single line containing number \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10^10000}). A line with a single zero terminates the input. Maximum size of input is \textbf{200000} bytes. \OutputFile Output for each test case should consist of a single integer on a line, indicating the number of numbers \textbf{X} satisfying the condition. Do not output leading zeros.
Ліміт часу 0.75 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
1
2
11
13
14003
767513456469789456166547987979741366664879441
0
Вихідні дані #1
0
1
1
0
60
0
Джерело Izhevsk STU Contest, Petrozavodsk training camp, February 6, 2009