#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;
}