#include <bits/stdc++.h>
using namespace std;
int bei[10]; //备用
map<long long, int> mp;
int main()
{
    int a[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    int res = 0;
    do
    {
        for (int i = 1; i < 9; i++)
        {
            memset(bei, 0, sizeof(bei)); //分配空间
            long long int ans, left = 0, right = 0, t = 0, x = 0, y = 0;
            for (int j = 0; j <= i; j++)
            {
                left = left * 10 + a[j];
            }
            x = left;
            x = x * 10;
            for (int k = i + 1; k < 9; k++)
            {
                right = right * 10 + a[k];
                x = x * 10 + a[k];
            }
            y = right;
            y = y * 10;
            for (int j = 0; j <= i; j++)
                y = y * 10 + a[j];

            ans = left * right;
            long long int ff = ans;
            while (ans > 0)
            {
                int x = ans % 10;
                ans = ans / 10;
                if (bei[x] == 0 && x != 0)
                {
                    bei[x] = 1;
                    t++;
                }
            }
            if (t == 9 && mp.count(x) == 0 && mp.count(y) == 0)
            {
                res++;
                mp[x] = 1;
                mp[y] = 1;
            }
        }
    } while (next_permutation(a, a + 9)); //全排列
    cout << res << endl;
    return 0;
}
