#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 30000000000000LL
#define GOLD 1.61803398874989484820458
const long long MAX_MOD = 1e6 + 3;
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long powering(long long now,long long now_go){
	long long ans = 1;
	while (now_go != 0) {
		if (now_go % 2 == 1) {
			ans *= now;
			ans %= MAX_MOD;
		}
		now *= now;
		now %= MAX_MOD;
		now_go /= 2;
	}
	return ans;
}
long long inv(long long now) {
	return powering(now, MAX_MOD - 2LL);
}
long long d;
long long geko[32] = {};
long long bobo[30] = {};
long long solve(long long now, long long now_digit, long long L) {
	if (L / 2 == now_digit) {
		if (L % 2 == 0) {
			if (d == now) {
				return 1;
			}
			else {
				return 0;
			}
		}
		else {
			if (d == now) {
				return 10LL;
			}
			else {
				return 0LL;
			}
		}
	}
	long long ans = 0;
	for (long long i = -9; i <= 9; ++i) {
		long long tea = geko[L - now_digit - 1] - geko[now_digit];
		tea *= i;
		tea += now;
		if (tea >= 0) {
			if (tea % geko[now_digit + 1] == d % geko[now_digit + 1]) {
				//ok
				long long geko = solve(tea, now_digit + 1, L);
				if (geko == 0) continue;
				if (now_digit == 0) {
					bobo[i + 9]--;
				}
				ans += geko * bobo[i+9];
				if (now_digit == 0) {
						bobo[i + 9]++;
				}
			}
		}
		else {
			tea += geko[18];
			if (tea % geko[now_digit + 1] == d % geko[now_digit + 1]) {
				long long geko = solve(tea - bobo[18], now_digit + 1, L);
				if (geko == 0)continue;
				if (now_digit == 0) {
						bobo[i + 9]--;
				}
				ans += geko * bobo[i + 9];
				if (now_digit == 0) {
						bobo[i + 9]++;
				}
			}
			tea -= geko[18];
		}
	}
	return ans;
}
int main() {
	for (int i = 0; i <= 9; ++i) {
		for (int q = 0; q <= 9; ++q) {
			bobo[i - q + 9]++;
		}
	}
	geko[0] = 1;
	for (int i = 1; i <= 18; ++i) {
		geko[i] = 10LL * geko[i-1];
	}
	cin >> d;
	if (d % 9 != 0) {
		cout << 0 << endl;
		return 0;
	}
	int len = to_string(d).length();
	long long ans = 0;
	for (long long digit = len; digit <= len * 2; ++digit) {
		ans += solve(0, 0, digit);
	}
	cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


ll ten[20];

ll val = 0;
void f(int L, int R, ll D, ll cur) {
  if (L > R) {
    if (D == 0) val += cur;
    return;
  }

  if (abs(D) > ten[R+1]) return;
  // cout << L << " " << R << " " << D << endl;

  if (L == R) {
    f(L+1, R-1, D, cur * 10);
  } else {

    for (int d = -9; d <= 9; d++) {
      ll D2 = D - (ten[R] - ten[L]) * d;
      ll ways = 10 - abs(d);
      if (L == 0) ways = 9 - abs(d);
      f(L+1, R-1, D2, cur * ways);
    }
  }

}

int main2() {
  ll D = nextLong();

  ten[0] = 1;
  REP(i, 19) ten[i+1] = ten[i] * 10;

  ll ans = 0;
  for (int k = 1; k <= 18; k++) {
    val = 0;
    f(0, k-1, D, 1);
    ans += val;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}