For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.

You are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?

Constraints

* D is an integer.
* 1 ≤ D < 10^9

Input

Input is given from Standard Input in the following format:


D


Output

Print the number of the positive integers N such that rev(N) = N + D.

Examples

Input

63


Output

2


Input

75


Output

0


Input

864197532


Output

1920
#include<bits/stdc++.h>
#include<vector>
#define LL long long
#define PI pair<LL,LL>
using namespace std;
LL D,St1[25],St2[25],P[25];
vector<LL>V;
void DFS(LL L,LL R,vector<PI>& Rec,LL Val,LL Cnt){
	if(L==R){
		Rec.push_back(PI(Val,Cnt));
		return; 
	}
	for(LL I=-9;I<=9;I++) DFS(L+1,R,Rec,Val+I*V[L],Cnt*((L==0)?St2[I+10]:St1[I+10]));
}
LL Solve(LL Len){
	V.clear();
	for(LL I=0;Len-I-1>I;++I) V.push_back(P[Len-I-1]-P[I]);
	vector<PI>An1,An2;
	LL Res=0;
	DFS(0,(V.size()+1)/2,An1,0,1);
	DFS((V.size()+1)/2,V.size(),An2,0,1);
	map<LL,LL>Mp;  Mp.clear();
	for(LL I=0;I<An2.size();I++) Mp[An2[I].first]+=An2[I].second;
	for(LL I=0;I<An1.size();I++) Res+=Mp[D-An1[I].first]*An1[I].second;
	if(Len&1) Res*=10;
	return Res;
}
int main(){
    scanf("%lld",&D);
    P[0]=1;
    for(LL I=1;I<=18;I++) P[I]=P[I-1]*10;
    for(LL I=0;I<=9;I++)
    	for(LL J=0;J<=9;J++){
    		St1[I-J+10]++;
			if(I&&J) St2[I-J+10]++;	
		}
	LL Ans=0;
	for(LL I=1;I<=18;I++) Ans+=Solve(I);
	printf("%lld",Ans);
	return 0;
}
