#include <cstdio>
#include <algorithm>
#define R register
#define ll long long
#define int long long
using namespace std;

ll base[40];
ll D;
ll ans=0;
ll st[40];

inline void dfs(int now,int len,ll sum)
{
	if(now==len/2+1)
	{
		if(sum!=D) return;
		ll tans=st[1]>=0?(9-st[1]):(9+st[1]);
		for(R int i=2;i<now;i++) tans=tans*(st[i]>=0?(10-st[i]):(10+st[i]));
		ans+=len&1?tans*10:tans;
		return ;
	}
	if(sum+10ll*(base[len-now]-base[now-1])<D) return ;
	if(sum-10ll*(base[len-now]-base[now-1])>D) return ;
	for(R int ss=-9;ss<=9;ss++)
	{
		st[now]=ss;
		dfs(now+1,len,sum+st[now]*(base[len-now]-base[now-1]));
	}
	return ;
}

signed main()
{
	scanf("%lld",&D);
	int tmp=0;ll d=D;
	base[0]=1;
	while(d) tmp++,d/=10;
	for(R int i=1;i<=18;i++) base[i]=base[i-1]*10;
	for(R int i=tmp;i<=18;i++) dfs(1,i,0);
	printf("%lld\n",ans);
	return 0;
}
### Prompt

Your task is to create 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 <cstdio>
#include <algorithm>
#define R register
#define ll long long
#define int long long
using namespace std;

ll base[40];
ll D;
ll ans=0;
ll st[40];

inline void dfs(int now,int len,ll sum)
{
	if(now==len/2+1)
	{
		if(sum!=D) return;
		ll tans=st[1]>=0?(9-st[1]):(9+st[1]);
		for(R int i=2;i<now;i++) tans=tans*(st[i]>=0?(10-st[i]):(10+st[i]));
		ans+=len&1?tans*10:tans;
		return ;
	}
	if(sum+10ll*(base[len-now]-base[now-1])<D) return ;
	if(sum-10ll*(base[len-now]-base[now-1])>D) return ;
	for(R int ss=-9;ss<=9;ss++)
	{
		st[now]=ss;
		dfs(now+1,len,sum+st[now]*(base[len-now]-base[now-1]));
	}
	return ;
}

signed main()
{
	scanf("%lld",&D);
	int tmp=0;ll d=D;
	base[0]=1;
	while(d) tmp++,d/=10;
	for(R int i=1;i<=18;i++) base[i]=base[i-1]*10;
	for(R int i=tmp;i<=18;i++) dfs(1,i,0);
	printf("%lld\n",ans);
	return 0;
}
```