def main():

    A, B = (int(i) for i in input().split())



    def trial_division(n):

        divs = []

        for i in range(1, int(n**0.5)+1):

            if n % i == 0:

                divs.append(i)

                if i != n//i:

                    divs.append(n//i)

        return set(divs)

    dA = trial_division(A)

    dB = trial_division(B)

    C = sorted(dA & dB)

    N = len(C)

    seen = [True]*(N)

    for i in range(1, N):

        for j in range(i+1, N):

            if seen[j] and C[j] % C[i] == 0:

                seen[j] = False

    print((seen.count(True)))





if __name__ == '__main__':

    main()

def main():

    N, M = (int(i) for i in input().split())



    def enum_divisors(n):

        # 約数列挙

        divs = set()

        for i in range(1, n+1):

            if i*i > n:

                break

            if n % i == 0:

                divs.add(i)

                if n//i != i:

                    # i が平方数でない

                    divs.add(n//i)

        return divs



    divs = enum_divisors(N) & enum_divisors(M)

    ans = 1

    v = 1

    from math import gcd

    for s in sorted(divs):

        if s == 1:

            continue

        if gcd(v, s) == 1:

            v *= s

            ans += 1

    print(ans)





if __name__ == '__main__':

    main()

def main():
    A, B = (int(i) for i in input().split())

    def trial_division(n):
        divs = []
        for i in range(1, int(n**0.5) + 1):
            if n % i == 0:
                divs.append(i)
                if i != n // i:
                    divs.append(n // i)
        return set(divs)

    dA = trial_division(A)
    dB = trial_division(B)
    C = sorted(dA & dB)
    N = len(C)
    seen = [True] * (N)
    for i in range(1, N):
        for j in range(i + 1, N):
            if seen[j] and C[j] % C[i] == 0:
                seen[j] = False
    print((seen.count(True)))


if __name__ == "__main__":
    main()

def main():
    N, M = (int(i) for i in input().split())

    def enum_divisors(n):
        # 約数列挙
        divs = set()
        for i in range(1, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                divs.add(i)
                if n // i != i:
                    # i が平方数でない
                    divs.add(n // i)
        return divs

    divs = enum_divisors(N) & enum_divisors(M)
    ans = 1
    v = 1
    from math import gcd

    for s in sorted(divs):
        if s == 1:
            continue
        if gcd(v, s) == 1:
            v *= s
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-    A, B = (int(i) for i in input().split()) +    N, M = (int(i) for i in input().split()) -    def trial_division(n): -        divs = [] -        for i in range(1, int(n**0.5) + 1): +    def enum_divisors(n): +        # 約数列挙 +        divs = set() +        for i in range(1, n + 1): +            if i * i > n: +                break -                divs.append(i) -                if i != n // i: -                    divs.append(n // i) -        return set(divs) +                divs.add(i) +                if n // i != i: +                    # i が平方数でない +                    divs.add(n // i) +        return divs -    dA = trial_division(A) -    dB = trial_division(B) -    C = sorted(dA & dB) -    N = len(C) -    seen = [True] * (N) -    for i in range(1, N): -        for j in range(i + 1, N): -            if seen[j] and C[j] % C[i] == 0: -                seen[j] = False -    print((seen.count(True))) +    divs = enum_divisors(N) & enum_divisors(M) +    ans = 1 +    v = 1 +    from math import gcd + +    for s in sorted(divs): +        if s == 1: +            continue +        if gcd(v, s) == 1: +            v *= s +            ans += 1 +    print(ans)