def d_disjoint_set_of_common_divisors():

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

    if A == 1 or B == 1:

        return 1



    def prime_factorization_dict(n):

        """nを素因数分解したときの素数の辞書"""

        from collections import defaultdict

        if n == 1:

            return {2: 0}  # 1は素数の0乗の積とみなす

        i, table = 2, defaultdict(int)

        while i**2 <= n:

            while n % i == 0:

                table[i] += 1

                n //= i

            i += 1

        if n > 1:

            table[n] = 1

        return set(table.keys())

    a_primekey = prime_factorization_dict(A)

    b_primekey = prime_factorization_dict(B)

    ans = []

    for a in a_primekey:

        if a in b_primekey:

            ans.append(a)

    return len(ans) + 1



print((d_disjoint_set_of_common_divisors()))
def d_disjoint_set_of_common_divisors():

    from fractions import gcd

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



    def prime_factorization_dict(n):

        """nを素因数分解したときの素数とその指数の辞書"""

        from collections import defaultdict

        if n == 1:

            return {2: 0}  # 1は素数の0乗の積とみなす

        i, table = 2, defaultdict(int)

        while i**2 <= n:

            while n % i == 0:

                table[i] += 1

                n //= i

            i += 1

        if n > 1:

            table[n] = 1

        return table

    g = gcd(A, B)

    return len(list(prime_factorization_dict(g).keys())) + 1 if g > 1 else 1



print((d_disjoint_set_of_common_divisors()))
def d_disjoint_set_of_common_divisors():
    A, B = [int(i) for i in input().split()]
    if A == 1 or B == 1:
        return 1

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数の辞書"""
        from collections import defaultdict

        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return set(table.keys())

    a_primekey = prime_factorization_dict(A)
    b_primekey = prime_factorization_dict(B)
    ans = []
    for a in a_primekey:
        if a in b_primekey:
            ans.append(a)
    return len(ans) + 1


print((d_disjoint_set_of_common_divisors()))

def d_disjoint_set_of_common_divisors():
    from fractions import gcd

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

    def prime_factorization_dict(n):
        """nを素因数分解したときの素数とその指数の辞書"""
        from collections import defaultdict

        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    g = gcd(A, B)
    return len(list(prime_factorization_dict(g).keys())) + 1 if g > 1 else 1


print((d_disjoint_set_of_common_divisors()))

+    from fractions import gcd + -    if A == 1 or B == 1: -        return 1 -        """nを素因数分解したときの素数の辞書""" +        """nを素因数分解したときの素数とその指数の辞書""" -        return set(table.keys()) +        return table -    a_primekey = prime_factorization_dict(A) -    b_primekey = prime_factorization_dict(B) -    ans = [] -    for a in a_primekey: -        if a in b_primekey: -            ans.append(a) -    return len(ans) + 1 +    g = gcd(A, B) +    return len(list(prime_factorization_dict(g).keys())) + 1 if g > 1 else 1