import java
.util.;
class Main{
static int n;
static int a[]= {1,2,3,4,5,6,7,8,9};
static int ans;
static int toint(int s,int e) {
int ans1=0;
int t=1;
for(int i=e;i>=s;i–) {
ans1+=a[i]t;
t=10;
}
return ans1;
}
static void f(int k) {
if(k==a.length) {
for(int i=0;i<7;i) {
int a1=toint(0,i);
if(a1>n) {
break;
}
for(int j=i+1;j<a.length-1;j) {
int b=toint(i+1,j);
int c=toint(j+1,a.length-1);
if(c==0) {
continue;
}
if(a1c+b==n*c) {
ans++;
}
}
}
}
for(int i=k;i<a.length;i++) {
int t=a[k];
a[k]=a[i];
a[i]=t;
f(k+1);
t=a[k];
a[k]=a[i];
a[i]=t;
}
}
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
n=in.nextInt();
f(0);
System.out.println(ans);
}
}