// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int d,cnt[19],ans=0;
ll pw[19];

void dfs(int p,ll s,int c,int lim) {
	if (p>=lim/2) {
		if (s==d) ans+=c*(lim&1?10:1);
		return;
	}
	int x=-9;
	while (x<9&&s+(x+1)*(pw[lim-p-1]-pw[p])<=d) ++x;
	dfs(p+1,s+x*(pw[lim-p-1]-pw[p]),c*(p==0&&x>=0?cnt[x+9]-1:cnt[x+9]),lim);
	if (++x<=9) dfs(p+1,s+x*(pw[lim-p-1]-pw[p]),c*(p==0&&x>=0?cnt[x+9]-1:cnt[x+9]),lim);
}

int main() {
	d=read();
	for (int i=0;i<=9;++i)
		for (int j=0;j<=9;++j) ++cnt[i-j+9];
	pw[0]=1;
	for (int i=1;i<=18;++i) pw[i]=10ll*pw[i-1];
	for (int i=1;i<=18;++i) dfs(0,0,1,i);
	printf("%d\n",ans);
	return 0;
}