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
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;

ll po[25];
pi chk(int l,bool f){
	int t=l/2;
	ll w=(po[l-t]-1)*(po[t]-1);
	if(f)return {-w,w-po[l-1]+po[t-1]};
	return {-w,w};
}
ll solve(int n,int p,ll rem){
	// digits, place, remain
	if(p<=n-p+1){
		if(rem)return 0;
		return po[p==n-p+1];
	}
	ll k=po[p-1]-po[n-p];
	pi s=chk(2*p-n,p==n);
	s.fi*=po[n-p],s.se*=po[n-p];
//	cerr<<n<<' '<<p<<' '<<rem<<' '<<k<<' '<<s.fi<<' '<<s.se<<endl;
	if(rem<s.fi||rem>s.se)return 0;
	ll res=0;
	for(int cur=-9;cur<=9;cur++){
		int cnt=min(cur+9,9)-max(cur,n==p?1:0)+1;
		if(cnt<=0)continue;
		// -cur 
		res+=cnt*solve(n,p-1,rem+k*cur); 
	}
	return res;
}

int D;
ll ans;

int main(){
	po[0]=1;
	for(int i=1;i<=18;i++)po[i]=po[i-1]*10;
	cin>>D;
	for(int i=1;i<=18;i++)ans+=solve(i,i,D);
	cout<<ans;
	return 0;
}