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

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

inline void dfs(int now,int len,ll sum)
{
	if(now==len/2+1)
	{
		if(sum!=D) return;
		int 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 ;
}

int main()
{
	scanf("%d",&D);
	int tmp=0;int d=D;while(d) tmp++,d/=10;
	base[0]=1;
	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("%d\n",ans);
	return 0;
}