#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int d;
ll ans = 0;
ll p[20];

ll Cal(int i , ll d , int len){
    if(i == len / 2)return (d == 0 ? ((len & 1) ? 10 : 1) : 0);
    ll tmp = p[len - i - 1] - p[i];
    ll tmp1 = d / tmp;
    ll ans = 0;
    if(tmp1 >= -9 && tmp1 <= 9)ans += Cal(i+1,d-tmp*tmp1,len) * (10 - abs(tmp1) - (i == 0));
    tmp1 += (d >= 0 ? 1 : -1);
    if(tmp1 >= -9 && tmp1 <= 9)ans += Cal(i+1,d-tmp*tmp1,len) * (10 - abs(tmp1) - (i == 0));
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w  ",stdout);
    }
    p[0] = 1;
    for(int i = 1 ; i <= 19 ; ++i)p[i] = p[i - 1] * 10;
    int d;cin >> d;
    for(int i = 1 ; i <= 18 ; ++i)ans += Cal(0,d,i);
    cout << ans;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

ll pw10[19], D, ans;
int bit[19];

void dfs(int l, int r, ll d, ll way)
{
	if(l > r)
	{
		if(d == -D) ans += way;
	}
	else
	{
		if(l == r) dfs(l+1, r-1, d, way*10);
		else
		{
			for(int i=-9; i<=9; i++)
			{
				ll base = d+i*pw10[r]-i*pw10[l];
				ll upb = base + pw10[r];
				ll lob = base - pw10[r];
				if(lob<=-D && -D<=upb) bit[l] = i, dfs(l+1, r-1, base, way*(10-abs(i)-(i<=0&&l==0)));
			}
		}
	}
}

int main()
{
	read(D);
	pw10[0] = 1;
	for(int i=1; i<=18; i++) pw10[i] = pw10[i-1] * 10;
	for(int i=1; i<=18; i++) dfs(0, i, 0, 1);
	printf("%lld\n", ans);
	return 0;
}
