F - Mirrored 解説 /

実行時間制限: 2 sec / メモリ制限: 256 MB

配点 : 800

問題文

正の整数 n に対し、n の十進表記(先頭に 0 を付けない)を左右に反転させて得られる整数を rev(n) と表記します。例えば、rev(123) = 321, rev(4000) = 4 です。

正の整数 D が与えられます。rev(N) = N + D であるような正の整数 N はいくつ存在するでしょうか?

制約

  • D は整数である。
  • 1 ≤ D < 10^9

入力

入力は以下の形式で標準入力から与えられる。

D

出力

rev(N) = N + D であるような正の整数 N の個数を出力せよ。


入力例 1

63

出力例 1

2

rev(N) = N + 63 であるような正の整数 N は、N = 18, 292 個存在します。


入力例 2

75

出力例 2

0

rev(N) = N + 75 であるような正の整数 N は存在しません。


入力例 3

864197532

出力例 3

1920

Score : 800 points

Problem Statement

For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.

You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?

Constraints

  • D is an integer.
  • 1 ≤ D < 10^9

Input

Input is given from Standard Input in the following format:

D

Output

Print the number of the positive integers N such that rev(N) = N + D.


Sample Input 1

63

Sample Output 1

2

There are two positive integers N such that rev(N) = N + 63: N = 18 and 29.


Sample Input 2

75

Sample Output 2

0

There are no positive integers N such that rev(N) = N + 75.


Sample Input 3

864197532

Sample Output 3

1920