#include<bits/stdc++.h>
using namespace std;
int num[9]={1,2,3,4,5,6,7,8,9};
int n,target,cnt=0;
int cal(int l, int r)
{
int res = 0 ;
for(int k = l + 1 ; k <= r ; k ++ )
res = res * 10 + num[k] ;
return res ;
}
int main()
{
cin >> target ;
do
{
for(int i = 0 ; i < 9 ; i++ )
for(int j = i + 1 ; j < 9 ; j ++ ) // 更像是指针
{
int a = cal(-1 , i ); // -1 在计算的过程中会成为 num [ 0 ] ;
int b = cal( i , j ); // i + 1 和 j 可能重合
int c = cal( j , 8 ); // num [8] 在计算的过程表示9 ;
if(c*target == a * c + b ) cnt ++ ;
}
}while(next_permutation( num , num + 9 ));
//全排列的参数不包括右边 num [ 8 ] 就已经是数组的边界,但是由于不包括 所以要写成 num [ 9 ] ;
cout<<cnt<<endl;
return 0 ;
}