#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

typedef long long LL;
	
using namespace std;

LL mi10[20];
LL a[10];
int l;
int cnt;

void dfs(int x,LL d,int c){
	if (x>l){
		if (d==0)cnt+=c;
		return;
	}
	if (d>=1ll*a[x]*10||d<=-1ll*a[x]*10)return;
	fo(i,1,9){
		if (x==1)dfs(x+1,d-1ll*i*a[x],c*(9-i));
		else dfs(x+1,d-1ll*i*a[x],c*(10-i));
	}
	if (x==1)dfs(x+1,d,c*9);
	else dfs(x+1,d,c*10);
	fo(i,-9,-1){
		if (x==1)dfs(x+1,d-1ll*i*a[x],c*(9+i));
		else dfs(x+1,d-1ll*i*a[x],c*(10+i));
	}
}

int main(){
	mi10[0]=1;
	fo(i,1,18)mi10[i]=mi10[i-1]*10;
	int d;
	scanf("%d",&d);
	int ans=0;
	for(int len=2;len<=18;len++){
		for(int i=1;i<=len/2;i++)a[i]=mi10[len-i]-mi10[i-1];
		l=len/2;
		cnt=0;
		dfs(1,d,1);
		if (len&1)cnt=cnt*10;
		ans=ans+cnt;
	}
	printf("%d\n",ans);
	return 0;
}