#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;

int D, len = 0;
i64 pw[20], result = 0;

void work(int x, int L, i64 rest, i64 way) {
  if (x == L / 2) {
    if (rest == 0) result += way * ((L & 1) ? 10 : 1);
    
    return;
  }

  if ((L & 1) && x == L / 2) {
    work(x + 1, L, rest, way * 9);
  } else {
    if (pw[L - x - 1] - pw[x] > 0) {
      for (int i = -9; i <= 10; ++i) {
	if ((pw[L - x - 1] - pw[x]) * i > rest) {
	  if (i != 10) work(x + 1, L, rest - (pw[L - x - 1] - pw[x]) * i, way * (9 - abs(i) + (x != 0)));
	  if (i > -9) work(x + 1, L, rest - (pw[L - x - 1] - pw[x]) * (i - 1), way * (9 - abs(i - 1) + (x != 0)));
	  break;
	}
      }
    } else {
      for (int i = 9; i >= -10; --i) {
	if ((pw[L - x - 1] - pw[x]) * i > rest) {
	  if (i != -10) work(x + 1, L, rest - (pw[L - x - 1] - pw[x]) * i, way * (9 - abs(i) + (x != 0)));
	  if (i < 9) work(x + 1, L, rest - (pw[L - x - 1] - pw[x]) * (i + 1), way * (9 - abs(i + 1) + (x != 0)));
	  break;
	}
      }
    }
  }
  
}

int main() {
  scanf("%d", &D);
  
  pw[0] = 1;

  for (int i = 1; i < 20; ++i) pw[i] = pw[i - 1] * 10;

  for (int i = 18; i; --i)
    work(0, i, D, 1);

  printf("%lld\n", result);
  return 0;
}

#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
int d,k,L,i,j,ten[15],a[25];
int s[25],mx,f[25];ll ans,an;
void dfs(int x,ll now){
	if (L-x>=k-1&&abs(now)>=10) return;
	if (now<0) return;
	int i;
	if (x>mx){
		an=a[s[1]+9]-(s[1]<=0);
		if (L&1) an*=10-(L==1);
		s[L]=-s[1];
		fo(i,2,mx) an*=a[s[i]+9],s[L-i+1]=-s[i];
		ll p=0;
		fd(i,L,1){
			p=p*10+s[i];
			if (p>d) return;
		}if (p==d) ans+=an;
		return;
	}
	fo(i,-9,9) s[x]=i,dfs(x+1,now*10-i);
}
int main(){
	ten[0]=1;
	fo(i,1,9) ten[i]=ten[i-1]*10;
	scanf("%d",&d);
	fo(i,1,9) if (d<ten[i]) break;
	k=i+1;
	fo(i,0,9)
	fo(j,0,9) a[i-j+9]++;
	fo(L,2,k<<1){
		mx=L>>1;
		memset(s,0,sizeof(s));
		dfs(1,0);
	}
	printf("%lld\n",ans);
}