#include<iostream>
#include<cstdio>

using namespace std;

int D,cnt[19],ans;
long long b[20];

void dfs(int x,long long num,int len,int sum){
	if(x>(len>>1)-1){if(num==D)ans+=sum*(len&1?10:1);return;}
	long long i=-9ll;while(i<9ll&&num+(i+1ll)*(b[len-x-1]-b[x])<=D)++i;
	dfs(x+1,num+i*(b[len-x-1]-b[x]),len,sum*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));
	if(++i<=9)dfs(x+1,num+i*(b[len-x-1]-b[x]),len,sum*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));
}

int main(){
	scanf("%d",&D);
	b[0]=1ll;for(int i=1;i<20;++i)b[i]=b[i-1]*10ll;
	for(int i=0;i<10;++i)for(int j=0;j<10;++j)++cnt[i-j+9];
	for(int i=1;i<20;++i)dfs(0,0,i,1);
	printf("%d",ans);
}
### 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<iostream>
#include<cstdio>

using namespace std;

int D,cnt[19],ans;
long long b[20];

void dfs(int x,long long num,int len,int sum){
	if(x>(len>>1)-1){if(num==D)ans+=sum*(len&1?10:1);return;}
	long long i=-9ll;while(i<9ll&&num+(i+1ll)*(b[len-x-1]-b[x])<=D)++i;
	dfs(x+1,num+i*(b[len-x-1]-b[x]),len,sum*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));
	if(++i<=9)dfs(x+1,num+i*(b[len-x-1]-b[x]),len,sum*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));
}

int main(){
	scanf("%d",&D);
	b[0]=1ll;for(int i=1;i<20;++i)b[i]=b[i-1]*10ll;
	for(int i=0;i<10;++i)for(int j=0;j<10;++j)++cnt[i-j+9];
	for(int i=1;i<20;++i)dfs(0,0,i,1);
	printf("%d",ans);
}
```