#include <bits/stdc++.h>
#define ll long long
using namespace std;
int D,cnt[19],ans;ll b[20];
void dfs(int x,ll res,int L,int now)
//x为当前的位数，res为当前的数值，L为总长度，now为满足条件的方案数

{
    if(x>(L>>1)-1){//x>=L/2
		if(res==D) ans+=now*(L&1?10:1);return;//如果总长为奇数，那么最中间的1位0~9任取
	}
	
    ll i=-9ll; 
	while(i<9ll  && res+(i+1ll)*(b[L-x-1]-b[x])<=D)  ++i;//不退位，第x位之差最大为i
	
    dfs(x+1,res+i*(b[L-x-1]-b[x]),L,now*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));
	
    if(++i<=9) dfs(x+1,res+i*(b[L-x-1]-b[x]),L,now*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));//退位，第x位之差最大为i
}
int main()
{
    scanf("%d",&D);
	
    b[0]=1ll;
	
	for(int i=1;i<19;++i) b[i]=b[i-1]*10ll;
	
    for(int i=0;i<=9;++i) 
		
		for(int j=0;j<=9;++j) ++cnt[i-j+9]; //构成i-j的方案数
	
    for(int i=1;i<=18;++i) dfs(0,0,i,1); //i为 假设数字的总长度，总位数为0~L-1
	
    printf("%d",ans);
}

### Prompt

In Cpp, your task is to solve 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 D,cnt[19],ans;ll b[20];
void dfs(int x,ll res,int L,int now)
//x为当前的位数，res为当前的数值，L为总长度，now为满足条件的方案数

{
    if(x>(L>>1)-1){//x>=L/2
		if(res==D) ans+=now*(L&1?10:1);return;//如果总长为奇数，那么最中间的1位0~9任取
	}
	
    ll i=-9ll; 
	while(i<9ll  && res+(i+1ll)*(b[L-x-1]-b[x])<=D)  ++i;//不退位，第x位之差最大为i
	
    dfs(x+1,res+i*(b[L-x-1]-b[x]),L,now*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));
	
    if(++i<=9) dfs(x+1,res+i*(b[L-x-1]-b[x]),L,now*(x==0&&i>=0?cnt[i+9]-1:cnt[i+9]));//退位，第x位之差最大为i
}
int main()
{
    scanf("%d",&D);
	
    b[0]=1ll;
	
	for(int i=1;i<19;++i) b[i]=b[i-1]*10ll;
	
    for(int i=0;i<=9;++i) 
		
		for(int j=0;j<=9;++j) ++cnt[i-j+9]; //构成i-j的方案数
	
    for(int i=1;i<=18;++i) dfs(0,0,i,1); //i为 假设数字的总长度，总位数为0~L-1
	
    printf("%d",ans);
}

```