#include <bits/stdc++.h>

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep1(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template <class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& p)
{
    return o << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& vc)
{
    o << "sz = " << vc.size() << endl
      << "[";
    for (const T& v : vc)
        o << v << ",";
    o << "]";
    return o;
}
using ll = long long;
constexpr ll MOD = 1000000007;

constexpr ll maxi[11] = {-1, 0, 81, 891, 9801, 98901, 998001, 9989001, 99980001, 999890001, 9999800001};
constexpr ll mini[11] = {-1, 0, 9, 99, 90, 990, 900, 9900, 9000, 99000, 90000};

inline ll digitmax(const ll n)
{
    for (ll i = 10; i >= 1; i--) {
        if (mini[i] <= n and n <= maxi[i]) {
            return i;
        }
    }
    return -1;
}

inline ll digitmin(const ll n)
{
    for (ll i = 1; i <= 10; i++) {
        if (mini[i] <= n and n <= maxi[i]) {
            return i;
        }
    }
    return -1;
}

inline ll pattern(ll sa, bool top)
{
    assert(-9 <= sa and sa <= 9);
    return (sa >= 0) ? ((top) ? 9 - sa : 10 - sa) : 10 + sa;
}

ll mohan(const ll n)
{
    ll ans = 0;
    for (ll i = 2; i <= 18; ++i) {
        ll x = 1;
        rep(j, i - 1) x *= 10;
        --x;
        ll y = 1;
        ll m = n;
        ll cnt = 1;
        bool fst = true;
        while (x >= 0) {
            if (x == 0) {
                cnt *= 10;
                break;
            }
            ll t = 0;
            while (m % (y * 10) / y != (9 * t) % 10)
                ++t;
            // cerr<<i<<" "<<m<<" "<<x<<" "<<y<<" "<<t<<" "<<cnt<<endl;
            m = abs(m - x * t);
            cnt *= (fst ? 9 : 10) - t;
            x = (x - 99 * y) / 10;
            y *= 10;
            fst = false;
        }
        if (!m)
            ans += cnt;
    }
    return ans;
}

ll solve(const ll d)
{
    if (d % 9 != 0) {
        //        cout << 0 << endl;
        return 0;
    }
    // const ll nmin = digitmin(d);
    // const ll nmax = digitmax(d);
    const ll nmin = 2;
    const ll nmax = 18;
    // show(nmin);
    // show(nmax);

    if (nmin == -1 or nmax == -1) {
        //        cout << -1 << endl;
        return 0;
    }


    ll count = 0;
    for (ll di = nmin; di <= nmax; di++) {
        const ll num = (di) / 2;
        vector<ll> coeff(num);
        for (ll i = 0; i < num; i++) {
            coeff[i] = pow(10LL, (di - 1 - i)) - pow(10LL, i);
        }
        vector<ll> digit(num);
        ll d_tmp = d;
        bool flag = true;
        for (ll i = 0; i < num; i++) {
            if (i == 0) {
                ll rem = d_tmp % 10;
                digit[i] = (10 - rem) % 10;
                d_tmp -= digit[i] * coeff[i];
                d_tmp /= 10;
                for (ll j = i + 1; j < num; j++) {
                    coeff[j] /= 10;
                }
            }
            if (i == num - 1) {
                if (di <= 3) {
                    if (d_tmp != 0) {
                        flag = false;
                    }
                    break;
                }
                if (d_tmp % coeff[i] != 0) {
                    flag = false;
                } else {
                    digit[i] = d_tmp / coeff[i];
                    if (not(digit[i] <= 9 and digit[i] >= -9)) {
                        flag = false;
                    }
                }
            } else if (i != 0) {
                ll rem = d_tmp % 10;
                digit[i] = (10 - rem) % 10;
                digit[i] -= ((digit[i] == 0) ? 0 : 10);
                if (digit[i] and coeff[i] <= d_tmp - digit[i] * coeff[i]) {
                    digit[i] += 10;
                }
                d_tmp -= digit[i] * coeff[i];
                d_tmp /= 10;
                for (ll j = i + 1; j < num; j++) {
                    coeff[j] /= 10;
                }
            }
        }
        ll pat = 1;
        if (flag) {
            // show(di);
            // show(digit);
            for (ll i = 0; i < num; i++) {
                pat *= pattern(digit[i], i == 0);
            }
            if (di % 2 == 1) {
                pat *= 10;
            }
            // show(pat);
            count += pat;
        }
    }
    //    cout << count << endl;
    return count;
}

int main()
{
    ll din;
    cin >> din;
    cout << solve(din) << endl;
    // show(solve(din));
    // show(mohan(din));

    // for (ll d = 9; d < 99999999; d += 9) {
    //     const ll ans = solve(d);
    //     const ll m = mohan(d);
    //     if (ans != m) {
    //         cout << "d:" << d << " ans:" << ans << " mohan:" << m << endl;
    //     }
    //     //        cout << "d:" << d << " ans:" << solve(d) << endl;
    // }

    return 0;
}


Measured memory_bytes: 256