from math import sqrt





def is_prime(x):

    if x < 2:

        return False

    for i in range(2, int(sqrt(x)) + 1):

        if x % i == 0:

            return False



    return True





def f(x):

    st = set()

    for i in range(1, int(sqrt(x)) + 1):

        if x % i == 0:

            st.add(i)

            st.add(x // i)



    return st





a, b = list(map(int, input().split()))



a_set = f(a)

b_set = f(b)



ans = 0

for e in a_set:

    if is_prime(e) or e == 1:

        if e in b_set:

            ans += 1



print(ans)

from math import sqrt





def prime_factorization(x):

    li = []

    num = x

    for i in range(2, int(sqrt(x)) + 1):

        if num % i == 0:

            cnt = 0

            while num % i == 0:

                cnt += 1

                num //= i

            li.append((i, cnt))



    if num != 1:

        li.append((num, 1))



    #if not li:

    #    li.append((x, 1))



    return li





a, b = list(map(int, input().split()))



a_pf = [(1, 1)] + prime_factorization(a)

b_pf = [(1, 1)] + prime_factorization(b)



ans = 0

for ap, at in a_pf:

    for bp, bt in b_pf:

        if ap == bp:

            ans += 1



print(ans)

from math import sqrt


def is_prime(x):
    if x < 2:
        return False
    for i in range(2, int(sqrt(x)) + 1):
        if x % i == 0:
            return False
    return True


def f(x):
    st = set()
    for i in range(1, int(sqrt(x)) + 1):
        if x % i == 0:
            st.add(i)
            st.add(x // i)
    return st


a, b = list(map(int, input().split()))
a_set = f(a)
b_set = f(b)
ans = 0
for e in a_set:
    if is_prime(e) or e == 1:
        if e in b_set:
            ans += 1
print(ans)

from math import sqrt


def prime_factorization(x):
    li = []
    num = x
    for i in range(2, int(sqrt(x)) + 1):
        if num % i == 0:
            cnt = 0
            while num % i == 0:
                cnt += 1
                num //= i
            li.append((i, cnt))
    if num != 1:
        li.append((num, 1))
    # if not li:
    #    li.append((x, 1))
    return li


a, b = list(map(int, input().split()))
a_pf = [(1, 1)] + prime_factorization(a)
b_pf = [(1, 1)] + prime_factorization(b)
ans = 0
for ap, at in a_pf:
    for bp, bt in b_pf:
        if ap == bp:
            ans += 1
print(ans)

-def is_prime(x): -    if x < 2: -        return False +def prime_factorization(x): +    li = [] +    num = x -        if x % i == 0: -            return False -    return True - - -def f(x): -    st = set() -    for i in range(1, int(sqrt(x)) + 1): -        if x % i == 0: -            st.add(i) -            st.add(x // i) -    return st +        if num % i == 0: +            cnt = 0 +            while num % i == 0: +                cnt += 1 +                num //= i +            li.append((i, cnt)) +    if num != 1: +        li.append((num, 1)) +    # if not li: +    #    li.append((x, 1)) +    return li -a_set = f(a) -b_set = f(b) +a_pf = [(1, 1)] + prime_factorization(a) +b_pf = [(1, 1)] + prime_factorization(b) -for e in a_set: -    if is_prime(e) or e == 1: -        if e in b_set: +for ap, at in a_pf: +    for bp, bt in b_pf: +        if ap == bp: