#include <bits/stdc++.h>
#define REP(i,n) for(LL i=0;i<(LL)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<LL,LL>
#define pll pair<LL,LL>

using namespace std;

LL D;
map<LL,LL> cnt0;
map<LL,LL> cnt1;

LL comb(LL k,LL d){
    LL nine=1;
    REP(i,k)nine*=10;
    nine--;
    vector<LL> ele;
    while(nine>0){
        LL p=(10-(abs(d)%10))*(d>0 ? -1:1);
        if(abs(p)==10)p=0;
        d = (d +p*nine)/10;
        ele.push_back(-p);
        nine/=100;
    }
    LL res=0;
    if(d==0){
        res=cnt0[ele[0]];
        for(LL i=1;i<ele.size();i++)res*=cnt1[ele[i]];
        if(k%2==0)res*=10;
    }
    return res;

}

int main(){

    cin>>D;
    for(LL i=1;i<10;i++){
        REP(j,10){
            cnt0[j-i]=cnt0[j-i]+1;
        }
    }
    REP(i,10)REP(j,10)cnt1[i-j]=cnt1[i-j]+1;

    LL ans=0;
    for(LL i=1;i<20;i++)ans+=comb(i,D);
    cout<<ans<<endl;

    return 0;
}