#include<bits/stdc++.h>
using namespace std;

const int maxn = 22;

long long d, det[maxn], ten[maxn];
int len, mid;
long long ans, temp;

void dfs(long long now, int depth, long long cnt, int flag)
{
    if (d == now && depth > mid) {
        temp += cnt;
        return;
    }
    if (depth > mid) {return;}
    long long rua = ten[depth] - ten[len + 1 - depth];
    for (int i = -9; i <= 9; i++)
    {
        if (llabs(now + rua * i - d) >= ten[len + 1 - depth]) continue;
        dfs(now + rua * i, depth + 1, cnt * (10 - flag - abs(i)), 0);
    }
}

void init ()
{
    ten[1] = 1;
    for (int i = 2; i <= 19; i++) ten[i] = ten[i - 1] * 10;
}

int main()
{
    //freopen("C:/Users/MACHENIKE/Desktop/data.in","r",stdin);
    scanf("%lld", &d);
    init();
    for (len = 1; len <= 19; len++)
    {
        temp = 0;
        mid = len / 2;
        dfs(0, 1, 1, 1);
        if (len & 1) temp *= 10;
        ans += temp;
    }
    printf("%lld", ans);
    return 0;
}
