# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(map(int, input().split(' ')))

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b
ans.add(1)

# print(fact_a, fact_b)
print(len(ans)) a, b = map(int, input().split(' ')) a map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' b def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr factorization arr = [] arr [] temp = n temp n for i in range(2, int(-(-n ** 0.55 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

     i range(2, int(-(-n ** 0.55 // 1)) + 1) range 2 int(-(-n ** 0.55 // 1)) + 1 int(-(-n ** 0.55 // 1)) int -(-n ** 0.55 // 1) -n ** 0.55 // 1 -n ** 0.55 n ** 0.55 n 0.55 1 1 if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

     temp % i == 0 temp % i temp i 0 cnt = 0 cnt 0 while temp % i == 0:
                cnt += 1
                temp //= i
             temp % i == 0 temp % i temp i 0 cnt += 1 cnt 1 temp //= i temp i arr.append([i, cnt]) arr.append arr append [i, cnt] i cnt if temp != 1:
        arr.append([temp, 1])

     temp != 1 temp 1 arr.append([temp, 1]) arr.append arr append [temp, 1] temp 1 if arr == []:
        arr.append([n, 1])

     arr == [] arr [] arr.append([n, 1]) arr.append arr append [n, 1] n 1 return arr arr n n f[0] for f in factorization(a) for f in factorization(a) f factorization(a) factorization a for f in factorization(a) f[0] f 0 fact_a = set([f[0] for f in factorization(a)]) fact_a set([f[0] for f in factorization(a)]) set [f[0] for f in factorization(a)] f[0] for f in factorization(b) for f in factorization(b) f factorization(b) factorization b for f in factorization(b) f[0] f 0 fact_b = set([f[0] for f in factorization(b)]) fact_b set([f[0] for f in factorization(b)]) set [f[0] for f in factorization(b)] ans = fact_a & fact_b ans fact_a & fact_b fact_a fact_b ans.add(1) ans.add ans add 1 print(len(ans)) print len(ans) len ans ans = fact_a & fact_b fact_a & fact_b ans fact_b = set([f[0] for f in factorization(b)]) set([f[0] for f in factorization(b)]) fact_b a, b = map(int, input().split(' ')) map(int, input().split(' ')) a b = map(int, input().split(' ')) map(int, input().split(' ')) b fact_a = set([f[0] for f in factorization(a)]) set([f[0] for f in factorization(a)]) fact_a def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr factorization
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b = map(int, input().split(' '))


# a = list(map(int, input().split(' ')))

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.55 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


fact_a = set([f[0] for f in factorization(a)])
fact_b = set([f[0] for f in factorization(b)])

ans = fact_a & fact_b
ans.add(1)

# print(fact_a, fact_b)
print(len(ans))
