#include <bits/stdc++.h>

typedef long long LL;
int D;
LL pw[20], pl[20];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	for (int i = *pw = 1; i < 20; ++i) pw[i] = pw[i - 1] * 10;
	std::cin >> D;
	if (D % 9 != 0) return std::cout << 0 << std::endl, 0;
	D /= 9; LL ans = 0;
	for (int dig = 1; dig <= 18; ++dig) {
		memset(pl, 0, sizeof pl);
		for (int j = 0; j < dig; ++j) {
			for (int k = 0; k <= 10; ++k)
				if (j >= k && j < dig - k - 1)
					pl[k] += pw[j];
		}
		LL ws = 1, dt = D;
		for (int k = 0; k <= 10; ++k) if (pl[k]) {
			LL t = dt % pw[k + 1] / pw[k];
			if (t > 9) { ws = 0; break; }
			dt = std::abs(dt - t * pl[k]);
			ws *= std::max(10 - (t + (k == 0)), 0ll);
		}
		if (dt) ws = 0;
		ans += ws * ((dig & 1) ? 10 - (dig == 1) : 1);
	}
	std::cout << ans << std::endl;
	return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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.

Examples

Input

63


Output

2


Input

75


Output

0


Input

864197532


Output

1920

### Response

```cpp
#include <bits/stdc++.h>

typedef long long LL;
int D;
LL pw[20], pl[20];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	for (int i = *pw = 1; i < 20; ++i) pw[i] = pw[i - 1] * 10;
	std::cin >> D;
	if (D % 9 != 0) return std::cout << 0 << std::endl, 0;
	D /= 9; LL ans = 0;
	for (int dig = 1; dig <= 18; ++dig) {
		memset(pl, 0, sizeof pl);
		for (int j = 0; j < dig; ++j) {
			for (int k = 0; k <= 10; ++k)
				if (j >= k && j < dig - k - 1)
					pl[k] += pw[j];
		}
		LL ws = 1, dt = D;
		for (int k = 0; k <= 10; ++k) if (pl[k]) {
			LL t = dt % pw[k + 1] / pw[k];
			if (t > 9) { ws = 0; break; }
			dt = std::abs(dt - t * pl[k]);
			ws *= std::max(10 - (t + (k == 0)), 0ll);
		}
		if (dt) ws = 0;
		ans += ws * ((dig & 1) ? 10 - (dig == 1) : 1);
	}
	std::cout << ans << std::endl;
	return 0;
}

```