/*
 * DATE : 2017-06-03
 * Algo :
*/
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define Long                    long long
#define Ulong                   unsigned long long
#define FOR(I,A,B)              for(long long i=0; i < n ; i++ )
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-9
#define F                       first
#define S                       second
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl;
#define Di(x)                   int x; cin>>x
#define in(x)                   input(x)
#define in2(x,y)                input(x), input(y)
#define in3(x,y,z)              input(x), input(y),input(z)
#define ins(x)                  scanf("%s",x)
#define ind(x)                  scanf("%lf",&x)
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)

template<class T > void input(T &x){
    char c = getchar();x = 0;
    for(;(c<48 || c>57);c = getchar());
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
}
inline long long bigmod(long long p,long long e,long long M){
    long long ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 1001;

long long p10[20];
long long pre[10];


int func(int n,int t)
{

    int ans = 0;
    for(int i = 0; i < 10;i ++ ) {
        for(int j = t; j <10; j ++ ) {
            if(i - j == n ) ans ++;
        }
    }
//    db(ans);
    return ans;
}

long long ans = 0;
vector<long long> base;
long long findMin(int pos)
{
    long long ret = 0;
    for(int i = pos;i < base.size(); i ++ ) {
        ret += -9LL * base[i];
    }
    return ret;
}
long long findMax(int pos)
{
    long long ret = 0;
    for(int i = pos;i < base.size(); i ++ ) {
        ret += 9LL * base[i];
    }
    return ret;
}
long long d;
long long solve(int now,long long sum)
{


    if(now == base.size()) {
        return (sum == d);
    }
    long long ret = 0;
    if(base[now]== 0) {
        if(sum == d ) return 10;
        return 0;
    }
    for(int i= -9;i<10;i++){
        int t = func(i, now == 0 ? 1: 0);
        long long p1 = findMin(now+1);
        long long p2 = findMax(now+1);
//        db(sum + base[now] * i + p1);
//        db(sum + base[now] * i + p2);
        if(sum + base[now] * i + p1 > d ) continue;
        if(sum + base[now] * i + p2 < d ) continue;

        ret += solve(now+1,sum + base[now] * i) * t ;


    }

    return ret;
}
int main()
{

    p10[0]=1;
    for(int i=1;i<20;i++) p10[i] = 10*p10[i-1];

    cin>>d;

//    long long br = 0;
//    for(int i = 1;i <= 100000;i ++ ) {
//        string t = to_string(i);
//        string v = t; reverse(v.begin(), v.end());
//        int num1 = 0, num2 = 0;
//        for(int i = 0; i < v.size() ; i ++ ) num1 = 10 * num1 + v[i] - '0';
//        for(int i = 0; i < t.size(); i ++ ) num2 = 10 * num2 + t[i] - '0';
//        if(num1 - num2 == d)  {
//            br ++;
//            cout << num2 <<" " << num1 << endl;
//        }
//    }
//    db(br);
    for(int n = 18; n >= 1; n-- ) {
        base.clear();
        for(int i = n , j = 0; i >= j; i --, j ++) {
            base.pb(p10[i]- p10[j]);
        }
//        for(auto a: base) printf("%d ",a); puts("");

        //db(base.size());
        ans += solve(0,0);
//        db(ans);


    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256