#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n; ll ans,pw[29],mx[29][29];
void solve(int l,int r,ll now,ll tmp,bool flag){
	if (l>r){
		if (!now) ans+=tmp; return;
	}
	if (abs(now)>mx[l][r]) return;
	int i,x;
	for (i=-9; i<=9; i++){
		if (l==r && i!=0) continue;
		x=(flag)?10:9; x-=abs(i);
		if (x) solve(l+1,r-1,now+i*(pw[r]-pw[l]),tmp*x,1);
	}
}
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=pw[0]=1; i<=17; i++) pw[i]=pw[i-1]*10;
	for (i=17; i>=0; i--)
		for (j=i; j<=17; j++) mx[i][j]=mx[i+1][j-1]+9*(pw[j]-pw[i]);
	for (i=0; i<=17; i++) solve(0,i,n,1,0);
	printf("%lld\n",ans);
	return 0;
}

### Prompt

Generate a Cpp solution to the following problem:

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>
#define ll long long
using namespace std;

int n; ll ans,pw[29],mx[29][29];
void solve(int l,int r,ll now,ll tmp,bool flag){
	if (l>r){
		if (!now) ans+=tmp; return;
	}
	if (abs(now)>mx[l][r]) return;
	int i,x;
	for (i=-9; i<=9; i++){
		if (l==r && i!=0) continue;
		x=(flag)?10:9; x-=abs(i);
		if (x) solve(l+1,r-1,now+i*(pw[r]-pw[l]),tmp*x,1);
	}
}
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=pw[0]=1; i<=17; i++) pw[i]=pw[i-1]*10;
	for (i=17; i>=0; i--)
		for (j=i; j<=17; j++) mx[i][j]=mx[i+1][j-1]+9*(pw[j]-pw[i]);
	for (i=0; i<=17; i++) solve(0,i,n,1,0);
	printf("%lld\n",ans);
	return 0;
}

```