#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

typedef long long LL;

LL K;
LL ans = 0;

map <int, int> mp;
vector <int> v;

vector <long long> coef[] = {
    {},
    {},
    {1LL},
    {11LL},
    {111LL, 10LL},
    {1111LL, 110LL},
    {11111LL, 1110LL, 100LL},
    {111111LL, 11110LL, 1100LL},
    {1111111LL, 111110LL, 11100LL, 1000LL},
    {11111111LL, 1111110LL, 111100LL, 11000LL},
    {111111111LL, 11111110LL, 1111100LL, 111000LL, 10000LL},
    {1111111111LL, 111111110LL, 11111100LL, 1111000LL, 110000LL},
    {11111111111LL, 1111111110LL, 111111100LL, 11111000LL, 1110000LL, 100000LL},
    {111111111111LL, 11111111110LL, 1111111100LL, 111111000LL, 11110000LL, 1100000LL},
    {1111111111111LL, 111111111110LL, 11111111100LL, 1111111000LL, 111110000LL, 11100000LL, 1000000LL},
    {11111111111111LL, 1111111111110LL, 111111111100LL, 11111111000LL, 1111110000LL, 111100000LL, 11000000LL},
    {111111111111111LL, 11111111111110LL, 1111111111100LL, 111111111000LL, 11111110000LL, 1111100000LL, 111000000LL, 10000000LL},
    {1111111111111111LL, 111111111111110LL, 11111111111100LL, 1111111111000LL, 111111110000LL, 11111100000LL, 1111000000LL, 110000000LL},
    {11111111111111111LL, 1111111111111110LL, 111111111111100LL, 11111111111000LL, 1111111110000LL, 111111100000LL, 11111000000LL, 1110000000LL, 100000000LL},
    {111111111111111111LL, 11111111111111110LL, 1111111111111100LL, 111111111111000LL, 11111111110000LL, 1111111100000LL, 111111000000LL, 11110000000LL, 1100000000LL}
    };

void bck(int pas, LL num, LL cnt, vector<LL> cf)
{
    if(pas >= cf.size())
    {
        if(num == K)    ans += cnt;
        return;
    }

    int st = -9, dr = 9;
    if(pas == 0)    st = -8, dr = 8;

    for(int i = st; i <= dr; i++)
    {
        LL newnum = num + (1LL * i * cf[pas]);
        LL newcnt = 9 - abs(i) + 1;
        if(pas == 0)    newcnt--;

        LL maxdif = 0LL;
        for(int i = pas + 1; i < cf.size(); i++)
            maxdif += cf[i];
        maxdif *= 9;

        if(newnum + maxdif < K) continue;
        if(newnum - maxdif > K) continue;

        bck(pas + 1, newnum, 1LL * cnt * newcnt, cf);
    }
}

void solve(int N, int M)
{
    int ans = 0;
    for(int i = 1; i <= M; i++)
    {
        int aux = i;
        int r = 0;
        while(aux)
        {
            r = r * 10 + aux % 10;
            aux /= 10;
        }
        int d = r - i;

        if(d == N)
        {
            ans++;
            printf("%d\n", i);
        }
    }

    cerr << ans << '\n';
    exit(0);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    int N;
    scanf("%d", &N);

    if(N % 9)
    {
        printf("0\n");
        return 0;
    }

    K = N / 9;
    int cif = -1;
    for(auto cf: coef)
    {
        cif++;
        LL cnt = 1LL;
        if(cif & 1)    cnt *= 10LL;
        bck(0, 0LL, cnt, cf);
    }

    printf("%lld\n", ans);
    return 0;

    /*for(int i = 1; i <= 1000000000; i++)
    {
        if(i % 1000000 == 0)    cerr << i << '\n';

        if(i % 10 == 0) continue;
        int aux = i;
        int r = 0;
        while(aux)
        {
            r = r * 10 + aux % 10;
            aux /= 10;
        }
        int d = r - i;
        if(d <= 0) continue;

        if(!mp.count(d))    v.push_back(d);
        mp[d]++;
    }

    sort(v.begin(), v.end());
    for(auto x: v)
        printf("%d -> %d\n", x, mp[x]);

    return 0; */
}


Measured memory_bytes: 256