#include <cstdio>

#define F(i, a, b) for (LL i = a; i <= b; i ++)
#define G(i, a, b) for (LL i = a; i >= b; i --)
#define pf printf

typedef long long LL;

const LL N = 1e7 + 10;
const LL M = 20;

using namespace std;

LL D, L, Ans, Sum, total, w[M];
LL ten[M], v[M], tot[M], TOT[M];

void Dfs(LL k, LL s, LL S) {
	if (s < 0) return;
	if (s + 10 * v[k] < D) return;
	if (s - 10 * v[k] > D) return;
	if (k > L) {
		if (s == D) {
			Sum += S;
//			printf("Yes\n");
		}
		return;
	}
	F(i, -9, 9)
		w[k] = i, Dfs(k + 1, s + v[k] * i, S * (k == 1 ? TOT[i + 9] : tot[i + 9]));
}

int main() {
	scanf("%lld", &D);
//	F(i, 1, N - 10) {
//		LL rev = 0;
//		for (LL x = i; x; rev = rev * 10 + (x % 10), x /= 10);
//		if (rev - i == D)
//			printf("%lld\n", i), total ++;
//	}

//	puts("");

	F(i, 0, 9)
		F(j, 0, 9)
			tot[i - j + 9] ++;
	F(i, 0, 9)
		F(j, 1, 9)
			TOT[i - j + 9] ++;

	ten[0] = 1;
	F(i, 1, 18)
		ten[i] = ten[i - 1] * 10LL;
	F(i, 2, 18) {
		L = i / 2, Sum = 0;
		F(j, 1, L)
			v[j] = ten[i - j] - ten[j - 1];
		Dfs(1, 0, 1);
		Ans += Sum * ((i & 1) ? 10 : 1);
//		pf("%d\n", i);
	}
	pf("%lld\n", Ans);
}
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 21001
#define int long long
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
const int MOD=1e9+7;
int n,a[MN],B[MN],x,mmh=0,mm[20][20][2][2];
inline int M(int x){return x<0?x+10:x;}
inline void work(int p,int n,int a,int b){
    if (mm[p][n][a][b]!=-1) {mmh+=mm[p][n][a][b];return;}
    int u=mmh;
    if (p+p-1==n){
        if (a==0&&b==0) mmh+=10*(B[p]==0);else
        if (a==1&&b==1) mmh+=10*(B[p]==9);
        return;
    }
    if (p+p-1>n){
        mmh+=a==b;
        return;
    }
    for (int i=p==1;i<=9;i++)
    for (int j=0;j<=9;j++)
    if (M(i-j-b)==B[p]&&(a==(j<i)||j==i)&&(M(j-i)==B[n+1-p]||M(j-1-i)==B[n+1-p])){
        if (a){
            if (j==i&&B[n+1-p]==0) continue;
            work(p+1,n,M(j-1-i)==B[n+1-p],i-b-j<0);
        }else{
            if (j==i&&B[n+1-p]==9) continue;
            work(p+1,n,M(j-1-i)==B[n+1-p],i-b-j<0);
        }
    }
    mm[p][n][a][b]=mmh-u;
}
signed main(){
    int i,j,k;
    x=n=read();
    if (n%9) return puts("0"),0;
    for (k=1;k<=10&&x;k++) B[k]=x%10,x/=10;k--;
    for (int i=k;i<=18;i++) memset(mm,-1,sizeof(mm)),work(1,i,0,0);
    printf("%lld\n",mmh);
}
