#include <iostream>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main()
{
    int ans = 0;

    for (int a = 1; a < 10; a++)
        for (int b = 1; b < 10; b++)
            for (int c = 1; c < 10; c++)
                for (int d = 1; d < 10; d++)
                    if (a != b && c != d)
                    {
                        int g1 = gcd(a * c, b * d), g2 = gcd(a * 10 + c, b * 10 + d);
                        if (a * c / g1 == (a * 10 + c) / g2 && b * d / g1 == (b * 10 + d) / g2)
                            ans++;
                    }

    cout << ans;
    return 0;
}
