#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
 
int n,d;
long long v[20],maxv[30];
 
long long qpow(int x,int y){
    long long ans=1;
    while(y){
        if(y&1)ans*=x;
        y>>=1,x*=x;
    }
    return ans;
}
 
long long dfs(long long x,int p){
    if(p==n)return (x==d);
    if(d<x-maxv[p]||d>x+maxv[p])return 0;
    long long ans=0;
    for(int i=-9;i<=9;i++){
        if(p)ans+=dfs(x+v[p]*i,p+1)*(10-abs(i));
        else if(i^9)ans+=dfs(x+v[p]*i,p+1)*(i>=0?9-i:10+i);
    }
    return ans;
}
 
int main(){
    scanf("%d",&d);
    long long ans=0;
    for(int i=1;i<=18;i++){
        memset(maxv,0,sizeof(maxv));
        n=i+1>>1;
        for(int j=0;j<n;j++)v[j]=qpow(10,i-j)-qpow(10,j);
        for(int j=0;j<n;j++)
        for(int k=j;k<n;k++)maxv[j]+=v[k]*9;
        ans+=dfs(0,0)*(i&1?1:10);
    }
    printf("%lld\n",ans);
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
using ll=long long ;

int D;

int res = 0;
ll pw[19];
int digit[19];

void dfs(int high, int low, ll dif, ll way, bool carry) {
    if (high < low) {
        if (dif == D) res += way;
    } else if(high == low) {
        dfs(high-1, low+1, dif, way*10, 0);
    } else {
        int d = digit[low] + carry; carry = 0;
        if (d == 10) d = 0, carry = 1;
        dfs(high-1, low+1, dif + (pw[low] - pw[high])*d, way*(10-d-(low==0 && d==0)), carry);
        if (d > 0) {
            dfs(high-1, low+1, dif + (pw[low] - pw[high])*(d-10), way*(d - (low==0)), 1);
        }
    }
}

void solve() {
    cin >> D;
    pw[0] = 1;
    for (int i = 1; i <= 18; i++) {
        pw[i] = 10*pw[i-1];
    }
    ll x = D;
    for (int i = 0; i <= 18; i++) {
        digit[i] = x%10;
        x/=10;
    }
    for (int len = 1; len <= 18; len++) {
        dfs(len-1, 0, 0, 1, 0);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}
