#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[19];
int D;
ll floor(ll x,ll y){
    return x/y-((x^y)<0&&x%y);
}
int main(){
    scanf("%d",&D);
    p[0]=1;
    for(int i=1;i<=18;i++)p[i]=p[i-1]*10;
    ll ans=0;
    function<void(int,int,ll,ll)> dfs=[&](int p1,int p2,ll diff,ll coeff){
        if(p1>=p2){
            if(p1==p2)coeff*=10;
            if(diff==0)ans+=coeff;
            return;
        }
        ll x=p[p2]-p[p1];
        {
            ll i=floor(diff,x);
            ll nd=diff-i*x,nc=coeff;
            if(abs(nd)<x&&abs(i)<=9){
                nc*=10-abs(i);
                if(p1==0)nc--;
                dfs(p1+1,p2-1,nd,nc);
            }
        }
        {
            ll i=floor(diff,x)+1;
            ll nd=diff-i*x,nc=coeff;
            if(abs(nd)<x&&abs(i)<=9){
                nc*=10-abs(i);
                if(p1==0)nc--;
                dfs(p1+1,p2-1,nd,nc);
            }
        }
    };
    for(int i=1;i<=18;i++)dfs(0,i-1,D,1);
    printf("%lld\n",ans);
    return 0;
}
### Prompt

Please formulate 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>
using namespace std;
typedef long long ll;
ll p[19];
int D;
ll floor(ll x,ll y){
    return x/y-((x^y)<0&&x%y);
}
int main(){
    scanf("%d",&D);
    p[0]=1;
    for(int i=1;i<=18;i++)p[i]=p[i-1]*10;
    ll ans=0;
    function<void(int,int,ll,ll)> dfs=[&](int p1,int p2,ll diff,ll coeff){
        if(p1>=p2){
            if(p1==p2)coeff*=10;
            if(diff==0)ans+=coeff;
            return;
        }
        ll x=p[p2]-p[p1];
        {
            ll i=floor(diff,x);
            ll nd=diff-i*x,nc=coeff;
            if(abs(nd)<x&&abs(i)<=9){
                nc*=10-abs(i);
                if(p1==0)nc--;
                dfs(p1+1,p2-1,nd,nc);
            }
        }
        {
            ll i=floor(diff,x)+1;
            ll nd=diff-i*x,nc=coeff;
            if(abs(nd)<x&&abs(i)<=9){
                nc*=10-abs(i);
                if(p1==0)nc--;
                dfs(p1+1,p2-1,nd,nc);
            }
        }
    };
    for(int i=1;i<=18;i++)dfs(0,i-1,D,1);
    printf("%lld\n",ans);
    return 0;
}
```