#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

ll D;
ll p[30];
ll get1[400],get2[400];

ll dfs(int pos,int num,ll val){
    ll s=0;
    //if(num==4&&pos==3)cout<<val<<endl;
   // if(pos==2&&num==4)puts("who");
    for(int i=pos;i<=num/2;i++){
        s+=p[num-i]-p[i-1];
    }
    if(val+9*s<D||val-9*s>D)return 0;
    if(pos==num/2+1)return val==D;
    ll cnt=0;
    for(int i=-9;i<=9;i++){
        //if(pos==2&&num==4&&i==1)cout<<get1[20]<<endl;
        if(pos==1){
            cnt+=dfs(pos+1,num,val+i*(p[num-pos]-p[pos-1]))*get2[i+20];
        }
        else{
            //if(pos==2&&num==4)cout<<val+i*(p[num-pos]-p[pos-1])<<endl;
            cnt+=dfs(pos+1,num,val+i*(p[num-pos]-p[pos-1]))*get1[i+20];
        }
    }
    return cnt;
}

int main(){
    p[0]=1;FOR(i,1,19)p[i]=p[i-1]*10;
    cin>>D;
    ll ans=0;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            get1[i-j+20]++;
        }
    }
    for(int i=0;i<=9;i++){
        for(int j=1;j<=9;j++){
            get2[i-j+20]++;
        }
    }
    for(int i=2;i<=20;i++){
        if(i&1)ans+=dfs(1,i,0)*10;
        else ans+=dfs(1,i,0);
    }
    cout<<ans<<endl;
}
