#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

ll rev(ll x,int n){
  ll ret=0;
  repeat(i,n){
    ret *= 10;
    ret += x%10;
    x /= 10;
  }
  return ret;
}

ll dfs(ll D,int n,int cnt,int dig,ll N){
  if(cnt>=n/2){
    return rev(N,n)==N+D? N:-1;
  }
  if(cnt>=0){
    if(dig>=0){
      ll d=dig;
      repeat(c,n-1-cnt) d*=10;
      N += d;
    }else{
      ll d=-dig;
      repeat(c,cnt) d*=10;
      N += d;
    }
  }
  ll ret = -1;
  for(int i=-9;i<=(cnt<0? 0:9);i++){
    ret = max(ret,dfs(D,n,cnt+1,i,N));
  }
  return ret;
}

int main(){
  ll D;cin >> D;
  if(D%9!=0){
    cout << 0 << endl;
    return 0;
  }
  int num10=0;
  while(D%10==0){
    D/=10;
    num10++;
  }
  string Dstr=to_string(D);
  int n = Dstr.length();
  //debug(n);
  ll ans = 0;
  repeat(d,7){
    int m = n+d;
    ll N=0;
    if(d>0){
      if(D%10!=9)break;
      if(d>1 && D%100!=89)break;
      repeat(c,d-1){
        N*=10;
        N+=9;
      }
      repeat(c,n){
        N*=10;
      }
      N+=1;
    }
    //debug(N);
    N = dfs(D,m,d-1,0,N);
    debug(N);
    if(N>0){
      string Nstr = to_string(N);
      while(Nstr.length()<m) Nstr = "0"+Nstr;
      ll a=1;
      repeat(j,(m+1)/2){
        int mi=Nstr[j]-'0',ma=Nstr[m-1-j]-'0';
        if(mi>ma)swap(mi,ma);
        a *= j==0? 9-ma+ (num10>0):10-(ma-mi);
      }
      debug(a);
      ans += a;
    }
  }
  if(ans>0&&num10>0){
    repeat(c,num10-1)ans *= 10;
    ans *= 9;
  }
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
array<Int, 18> POW10;
int main()
{
    POW10[0] = 1;
    for (int i = 1; i < POW10.size(); i++) POW10[i] = POW10[i-1] * 10;
    int D; cin >> D;
    int digits = 0;
    for (int val = 1; val <= D; val *= 10, digits++) {}
    Int ans = 0;
    for (int d = digits; d <= digits*2; d++) {
        vector<Int> A, S = {0};
        for (int k = d/2; k < d; k++) {
            A.push_back(POW10[k] - POW10[d-1-k]);
            S.push_back(S.back() + A.back());
        }
        function<void(int, Int, Int)> recur = [&](int idx, Int rest, Int acc) {
            int ten = (idx == A.size()-1 ? 9 : 10);
            if (idx == 0) {
                if (A[0] == 0) { if (rest == 0) ans += acc * ten; }
                else if (rest % A[0] == 0 && abs(rest / A[0]) <= 9) ans += acc * (ten - abs(rest / A[0]));
            } else {
                for (int i = -9; i <= 9; i++) {
                    Int r = rest - i * A[idx];
                    if (abs(r) <= abs(S[idx]*9)) recur(idx-1, r, acc * (ten - abs(i)));
                }
            }
        };
        recur(A.size()-1, D, 1);
    }
    cout << ans << '\n';
    return 0;
}