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

#define ll long long 

int t,m,n,a[60];
ll f[60],ans;

void dfs(int x,int n,ll sum){
    if(x==n/2+1){
        if(sum==m){
            ll now=a[1]>=0?(9-a[1]):(9+a[1]);
            for(int i=2;i<x;i++)now=now*(a[i]>=0?(10-a[i]):(10+a[i]));
            ans+=n&1?now*10:now;
        }
        return;
    }
    if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m) return ;
    for(int i=-9;i<10;i++){
        a[x]=i;
        dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
    }
}

int main(){
	ios::sync_with_stdio(false);
	cin>>m;
	t=m;
	f[0]++;
    while(t){
    	n++;
    	t/=10;
	}
    for(int i=1;i<=18;i++) f[i]=f[i-1]*10;
    for(int i=n;i<=18;i++) dfs(1,i,0);
    cout<<ans;
}
### Prompt

Please create a solution in cpp 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>
using namespace std;

#define ll long long 

int t,m,n,a[60];
ll f[60],ans;

void dfs(int x,int n,ll sum){
    if(x==n/2+1){
        if(sum==m){
            ll now=a[1]>=0?(9-a[1]):(9+a[1]);
            for(int i=2;i<x;i++)now=now*(a[i]>=0?(10-a[i]):(10+a[i]));
            ans+=n&1?now*10:now;
        }
        return;
    }
    if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m) return ;
    for(int i=-9;i<10;i++){
        a[x]=i;
        dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
    }
}

int main(){
	ios::sync_with_stdio(false);
	cin>>m;
	t=m;
	f[0]++;
    while(t){
    	n++;
    	t/=10;
	}
    for(int i=1;i<=18;i++) f[i]=f[i-1]*10;
    for(int i=n;i<=18;i++) dfs(1,i,0);
    cout<<ans;
}
```