/* GCC */

#include <stdio.h>

inline bool check(int a, int b, int c)
{
    return a != b && a != c && b != c && a * b % c == 0 && a * c % b == 0 && b * c % a == 0;
}

int main()
{
    freopen("numbers.in", "r", stdin);
    freopen("numbers.out", "w", stdout);

    int a, b;
    scanf("%d %d", &a, &b);

    int ans = 0;

    for (int c = a * b; c >= 1; c--)
        if (check(a, b, c))
            ans++;

    printf("%d\n", ans);

    return 0;
}
