#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int rec[10];
int64 ret;
int dp[20];
int64 c[20], sum[20];
int64 p10[20];

void solve(int64 rem, int pos, int len) {
  // trace(rem, pos, len);
  if (pos == len / 2) {
    if (rem != 0) return;
    int64 cur = 1;
    for (int i = 0; i < pos; ++i) {
      int t = dp[rec[i] + 9];
      if (i == 0) --t;
      cur *= t;
    }
    if (len % 2 == 1) cur *= 10;
    ret += cur;
    return;
  }
  int low = -9, high = 9;
  if (pos == 0) low = 0;
  int64 best_p = 1LL << 60, best_n = -(1LL << 60);
  int best_pi = -1, best_ni = -1;
  for (int i = low; i <= high; ++i) {
    int64 cur = rem - c[pos] * i;
    if ((sum[len / 2] - sum[pos + 1]) * 9 < abs(cur)) continue;
    rec[pos] = i;
    solve(cur, pos + 1, len);
  }
  return;
  for (int i = low; i <= high; ++i) {
    int64 cur = rem - c[pos] * i;
    if (cur >= 0) {
      if (best_p > cur) {
        best_p = cur;
        best_pi = i;
      }
    } else {
      if (best_n < cur) {
        best_n = cur;
        best_ni = i;
      }
    }
  }
  // trace(best_p, best_pi, best_n, best_ni);
  if (best_pi != -1) {
    rec[pos] = best_pi;
    solve(best_p, pos + 1, len);
  }
  if (best_ni != -1) {
    rec[pos] = best_ni;
    solve(best_n, pos + 1, len);
  }
}

int64 rev(int64 n) {
  int64 ret = 0;
  for (; n; n /= 10) {
    ret = ret * 10 + n % 10;
  }
  return ret;
}

int main() {
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      dp[i - j + 9]++;
    }
  }

  int64 D;
  scanf("%lld", &D);
  if (D % 9) {
    puts("0");
    return 0;
  }
  p10[0] = 1;
  for (int i = 1; i < 20; ++i) {
    p10[i] = p10[i - 1] * 10;
  }
  // // brute
  // trace("brute");
  // ret = 0;
  // for (int64 i = 1e8; i < 1e9; ++i) {
  //   if (rev(i) - i == D) {
  //     vector<int> digits(9);
  //     int u = 8;
  //     for (int64 x = i; x; x /= 10) {
  //       digits[u] = x % 10;
  //       --u;
  //     }
  //     printf("%lld: ", i);
  //     int64 s = 0;
  //     for (int j = 0; j < 4; ++j) {
  //       printf("%d%c", digits[8 - j] - digits[j], " \n"[j + 1 == 4]);
  //       s += (digits[8 - j] - digits[j]) * (p10[8 - j] - p10[j]);
  //     }
  //     printf("%lld\n", s - D);
  //   }
  // }
  // printf("%lld\n", ret);
  // return 0;

  ret = 0;
  for (int len = 2; len <= 20; ++len) {
    sum[0] = 0;
    for (int i = 0; i < len / 2; ++i) {
      c[i] = p10[len - 1 - i] - p10[i];
      sum[i + 1] = sum[i] + c[i];
    }
    solve(D, 0, len);
    // trace(len, ret);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256