#include <bits/stdc++.h>
                            #include<iostream>
                            #include<cstdio>
                            #include<vector>
                            #include<queue>
                            #include<map>
                            #include<cstring>
                            #include<string>
                            #include <math.h>
                            #include<algorithm>
                        //    #include <boost/multiprecision/cpp_int.hpp>
                            #include<functional>
                     #define int long long
                            #define inf  1000000007
                            #define pa pair<int,int>
                            #define ll long long
                            #define pal pair<double,int>
                            #define ppa pair<string,pa>
                            #define ssa pair<string,int>
                            #define  mp make_pair
                            #define  pb push_back
                            #define EPS (1e-10)
                            #define equals(a,b) (fabs((a)-(b))<EPS)
                     
                            using namespace std;
                     //priority_queue<int, vector<int>, greater<int> > que;
                            class Point{
                            	public:
                            	double x,y;
                            	Point(double x=0,double y=0):x(x),y(y) {}
                            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
                            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
                            	Point operator * (double a) {return Point(x*a,y*a);}
                            	Point operator / (double a) {return Point(x/a,y/a);}
                            	double absv() {return sqrt(norm());}
                            	double norm() {return x*x+y*y;}
                            	bool operator < (const Point &p) const{
                            		return x != p.x ? x<p.x: y<p.y;
                            	}
                            	bool operator == (const Point &p) const{
                            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
                            	}
                            };
                            typedef Point Vector;
                     
                            struct Segment{
                            Point p1,p2;
                            };
                     
                        double hen(Vector a){
                        if(fabs(a.x)<EPS && a.y>0) return acos(0);
                        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
                        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
                        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
                        else if(a.y>0) return acos(a.x/a.absv());
                        else return 2*acos(0)+acos(-a.x/a.absv());
                     
                        }
                     
                string itos( int i ) {
                ostringstream s ;
                s << i ;
                return s.str() ;
                }
                 
                int gcd(int v,int b){
                	if(v>b) return gcd(b,v);
                	if(v==b) return b;
                	if(b%v==0) return v;
                	return gcd(v,b%v);
                }
                            double dot(Vector a,Vector b){
                            	return a.x*b.x+a.y*b.y;
                            }
                            double cross(Vector a,Vector b){
                            	return a.x*b.y-a.y*b.x;
                            }
                        
                double distans(double x1,double y1,double x2,double y2){
                	double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
                	return sqrt(rr);
                	
                }


                         //----------------kokomade tenpure------------

int d;
int y[10000]={0};


int rev(int i){
	string s=itos(i);
	reverse(s.begin(), s.end());
	return stoi(s);
}
int sa(int i){
	return rev(i)-i;
}
int we[19]={1,2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,1,0};
int we2[19]={1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1};
int ds[22];
int ans=0;
void dfs(int q,vector<int> ve,int keta){
//	cout<<q<<" "<<keta<<endl;
	if(keta>22) return;
	if(ve.size()>0){
	if(ve[ve.size()-1]>9 || ve[ve.size()-1]<-9) return ;
	}
	if(keta<-1) return;
	if(keta==-1){
		if(ve.size()==0) return;
		if(q!=0) return;
		int r=1;
		for(int i=0;i<ve.size();i++){
			if(i==0)	r*= we[ve[i]+9];
			else r*= we2[ve[i]+9];
		}
//		cout<<r<<endl;
		ans +=r;
//		for(int i=0;i<ve.size();i++) cout<<ve[i]<<" ";
//		cout<<endl;
		return;
	}
	
	if(keta==0){
		if(ve.size()==0) return;
		if(q!=0) return;
		int r=1;
		for(int i=0;i<ve.size();i++){
			if(i==0)	r*= we[ve[i]+9];
			else r*= we2[ve[i]+9];
		}
		r *= 10;
		ans +=r;
//		cout<<r<<endl;
//		for(int i=0;i<ve.size();i++) cout<<ve[i]<<" ";
//		cout<<endl;
		return;
	}
	
	
	
	if(q>0){
		ve.pb(q%10);
		dfs((q-(q%10)*ds[keta])/10,ve,keta-2);
		ve.pop_back();
		int r=-(10-q%10);
		if(q%10==0) return;
		ve.pb(r);
		dfs((q-(r)*ds[keta])/10,ve,keta-2);
	}
	else{
		int qq= -q;
		ve.pb(-(qq%10));
		dfs((q-(-(qq%10))*ds[keta])/10,ve,keta-2);
		ve.pop_back();
		int r=(10-(qq%10));
		if(qq%10==0) return;
		ve.pb(r);
		dfs((q-(r)*ds[keta])/10,ve,keta-2);
	}
}

signed  main(){
cin>>d;

	ds[0]=0;
	ds[1]=1;
	for(int i=2;i<=22;i++) ds[i]=ds[i-1]*10+1;
	
	if(d%9!=0){
		cout<<0<<endl;
		return 0;
	}
	string s=itos(d/9);
	int y=s.length();
	
	
	vector<int> ve,ve2,ve3;
ans=0;
	for(int i=0;i<=20;i++){
		dfs(d/9,ve,i+1);
		ve.clear();
	}
	cout<<ans<<endl;
	/*
	for(int i=1;i<10000;i++){
		int u=sa(i);
		if(u<=0) continue;
	//	y[u/9]++;
	}
	for(int i=0;i<10000;i++) cout<<i<<" "<<y[i]<<endl;
	*/
 //	cout<<i<<endl;
 	//  	printf("%.10f\n",ans[n-1]);
                    	return 0;
}

Measured memory_bytes: 256