#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;

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

ll solve(const ll d)
{
    if (d % 9 != 0) {
        return 0;
    }
    const ll nmin = 2;
    const ll nmax = 18;

    if (nmin == -1 or nmax == -1) {
        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) {
            for (ll i = 0; i < num; i++) {
                pat *= pattern(digit[i], i == 0);
            }
            if (di % 2 == 1) {
                pat *= 10;
            }
            count += pat;
        }
    }
    //    cout << count << endl;
    return count;
}

int main()
{
    ll din;
    cin >> din;
    cout << solve(din) << endl;
    return 0;
}


Measured memory_bytes: 256