#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll maxn=1e5+10;
ll mm,m,n,a[60];
ll f[60];
ll ans;
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
void dfs(ll x,ll n,ll sum){
    if(x==n/2+1){
        if(sum==m){
           	ll now=a[1]>=0?(9-a[1]):(9+a[1]);
            for(register ll i=2;i<x;i++)
				now*=(a[i]>=0?(10-a[i]):(10+a[i]));
            ans+=n&1?now*10:now;
        }
        return ;
    }
    if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m)
		return ;
    for(register ll i=-9;i<10;i++){
        a[x]=i;
        dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
    }
}
int main(){
    read(m);
	mm=m;f[0]=1;
    while(mm) n++,mm/=10;
    for(register ll i=1;i<=18;i++) f[i]=f[i-1]*10;
    for(register ll i=n;i<=18;i++) dfs(1,i,0);
    printf("%lld\n",ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

__int128_t abs128(__int128_t val){return val<0?-val:val;}

ostream &operator<<(ostream &os,__int128_t val){
  if(ostream::sentry(os)){
    __uint128_t tmp=abs128(val);
    char buf[64];
    char *d=end(buf);
    do{
      --d;
      *d=char(tmp%10+'0');
      tmp/=10;
    }while(tmp);
    if(val<0) *--d='-';
    int len=end(buf)-d;
    if(os.rdbuf()->sputn(d,len)!=len){
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}

istream &operator>>(istream &is,__int128_t &val){
  string s;
  is>>s;
  val=0;
  for(int i=0;i<(int)s.size();i++)
    if(isdigit(s[i])) val=val*10+s[i]-'0';
  if(s[0]=='-') val*=-1;
  return is;
}

//INSERT ABOVE HERE
signed main(){
  using ll = __int128_t;

  ll d;
  cin>>d;
  const ll MAX = 37;
  ll ans=0;

  vector<ll> po(MAX,1);
  for(int i=0;i+1<MAX;i++)
    po[i+1]=po[i]*10;

  vector<ll> c1(12,0),c2(12,0);
  for(int i=1;i<10;i++)
    for(int j=1;j<=i;j++)
      c1[abs(i-j)]++;

  for(int i=0;i<10;i++)
    for(int j=0;j<=i;j++)
      c2[abs(i-j)]++;

  for(int l=2;l<=MAX;l++){
    // [s, t]
    ans+=
      MFP([&](auto dfs,ll s,ll t,ll w)->ll{
            if(s>=t){
              if(w!=0) return 0;
              return s==t?10:1;
            }
            ll dif=po[t]-po[s];
            ll x=w/dif;
            if(x>=10) return 0;

            ll res=0;
            res+=(s==0?c1:c2)[x+0]*dfs(s+1,t-1,abs128(w-(x+0)*dif));
            res+=(s==0?c1:c2)[x+1]*dfs(s+1,t-1,abs128(w-(x+1)*dif));
            return res;
          })(0,l-1,d);
  }
  cout<<ans<<endl;
  return 0;
}
