from math import sqrt

A, B = map(int, input().split())

def divisor(a, b):
    max_num = int(sqrt(a))
    divisor_list = []
    for i in range(1, max_num + 1):
        if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
        tmp = a//i
        if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

    return list(set(divisor_list))

common_list = divisor(A, B)
common_list.sort()

# print(common_list)

length = len(common_list)
max_common = common_list[-1]
prods = []
dic = {c: 0 for c in common_list}

for i in range(1, length):
    for j in range(1, length):
        prod = common_list[i] * common_list[j]
        if prod > max_common:
            continue
        else:
            dic[prod] = 1
ans = 0
for c in common_list:
    if dic[c] == 0:
        ans += 1
        # print(c)

print(ans) from math import sqrt A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B def divisor(a, b):
    max_num = int(sqrt(a))
    divisor_list = []
    for i in range(1, max_num + 1):
        if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
        tmp = a//i
        if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

    return list(set(divisor_list)) divisor max_num = int(sqrt(a)) max_num int(sqrt(a)) int sqrt(a) sqrt a divisor_list = [] divisor_list [] for i in range(1, max_num + 1):
        if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
        tmp = a//i
        if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

     i range(1, max_num + 1) range 1 max_num + 1 max_num 1 if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
         a % i == 0 and b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 divisor_list.append(i) divisor_list.append divisor_list append i tmp = a//i tmp a//i a i if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

     a % tmp == 0 and b % tmp == 0 a % tmp == 0 a % tmp a tmp 0 b % tmp == 0 b % tmp b tmp 0 divisor_list.append(tmp) divisor_list.append divisor_list append tmp return list(set(divisor_list)) list(set(divisor_list)) list set(divisor_list) set divisor_list a a b b common_list = divisor(A, B) common_list divisor(A, B) divisor A B common_list.sort() common_list.sort common_list sort length = len(common_list) length len(common_list) len common_list max_common = common_list[-1] max_common common_list[-1] common_list -1 prods = [] prods [] c: 0 for c in common_list for c in common_list c common_list for c in common_list c 0 dic = {c: 0 for c in common_list} dic {c: 0 for c in common_list} for i in range(1, length):
    for j in range(1, length):
        prod = common_list[i] * common_list[j]
        if prod > max_common:
            continue
        else:
            dic[prod] = 1 i range(1, length) range 1 length for j in range(1, length):
        prod = common_list[i] * common_list[j]
        if prod > max_common:
            continue
        else:
            dic[prod] = 1 j range(1, length) range 1 length prod = common_list[i] * common_list[j] prod common_list[i] * common_list[j] common_list[i] common_list i common_list[j] common_list j if prod > max_common:
            continue
        else:
            dic[prod] = 1 prod > max_common prod max_common continue dic[prod] = 1 dic[prod] dic prod 1 ans = 0 ans 0 for c in common_list:
    if dic[c] == 0:
        ans += 1
        # print(c) c common_list if dic[c] == 0:
        ans += 1
        # print(c) dic[c] == 0 dic[c] dic c 0 ans += 1 ans 1 print(ans) print ans B = map(int, input().split()) map(int, input().split()) B length = len(common_list) len(common_list) length prods = [] [] prods dic = {c: 0 for c in common_list} {c: 0 for c in common_list} dic A, B = map(int, input().split()) map(int, input().split()) A ans += 1 1 ans prod = common_list[i] * common_list[j] common_list[i] * common_list[j] prod common_list = divisor(A, B) divisor(A, B) common_list max_common = common_list[-1] common_list[-1] max_common def divisor(a, b):
    max_num = int(sqrt(a))
    divisor_list = []
    for i in range(1, max_num + 1):
        if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
        tmp = a//i
        if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

    return list(set(divisor_list)) def divisor(a, b):
    max_num = int(sqrt(a))
    divisor_list = []
    for i in range(1, max_num + 1):
        if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
        tmp = a//i
        if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

    return list(set(divisor_list)) divisor ans = 0 0 ans
from math import sqrt

A, B = map(int, input().split())

def divisor(a, b):
    max_num = int(sqrt(a))
    divisor_list = []
    for i in range(1, max_num + 1):
        if a % i == 0 and b % i == 0:
            divisor_list.append(i)
            # for j in divisor_list:
            #     if a % (i*j) == 0 and b % (i*j) == 0:
            #         divisor_list.append(i)
            # divisor_list.append(i)
        tmp = a//i
        if a % tmp == 0 and b % tmp == 0:
            divisor_list.append(tmp)
            # for j in divisor_list:
            #     if a % (tmp*j) == 0 and b % (tmp*j) == 0:

    return list(set(divisor_list))

common_list = divisor(A, B)
common_list.sort()

# print(common_list)

length = len(common_list)
max_common = common_list[-1]
prods = []
dic = {c: 0 for c in common_list}

for i in range(1, length):
    for j in range(1, length):
        prod = common_list[i] * common_list[j]
        if prod > max_common:
            continue
        else:
            dic[prod] = 1
ans = 0
for c in common_list:
    if dic[c] == 0:
        ans += 1
        # print(c)

print(ans)