A, B = map(int,input().split())
P = [1]
a = set([1,A])
b = set([1,B])
for k in range(2,2+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
    elif A%k == 0:
        a.add(A//k)
    elif B%k == 0:
        b.add(B//k)

P += list(a&b)
P.sort()
U = set([])
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e)
print(len(U)) A, B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B P = [1] P [1] 1 a = set([1,A]) a set([1,A]) set [1,A] 1 A b = set([1,B]) b set([1,B]) set [1,B] 1 B for k in range(2,2+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
    elif A%k == 0:
        a.add(A//k)
    elif B%k == 0:
        b.add(B//k) k range(2,2+int(max(A,B)**(1/2))) range 2 2+int(max(A,B)**(1/2)) 2 int(max(A,B)**(1/2)) int max(A,B)**(1/2) max(A,B) max A B 1/2 1 2 if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
    elif A%k == 0:
        a.add(A//k)
    elif B%k == 0:
        b.add(B//k) A%k == 0 and B%k == 0 A%k == 0 A%k A k 0 B%k == 0 B%k B k 0 P.append(k) P.append P append k a.add(A//k) a.add a add A//k A k b.add(B//k) b.add b add B//k B k elif A%k == 0:
        a.add(A//k)
     A%k == 0 A%k A k 0 a.add(A//k) a.add a add A//k A k elif B%k == 0:
        b.add(B//k) B%k == 0 B%k B k 0 b.add(B//k) b.add b add B//k B k P += list(a&b) P list(a&b) list a&b a b P.sort() P.sort P sort U = set([]) U set([]) set [] def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b) gcd if b == 0:
        return a
     b == 0 b 0 return a a return gcd(b,a%b) gcd(b,a%b) gcd b a%b a b a a b b for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e) e P flag = 1 flag 1 for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
     used U if gcd(e,used) != 1:
            flag = 0
            break
     gcd(e,used) != 1 gcd(e,used) gcd e used 1 flag = 0 flag 0 break if flag == 1:
        U.add(e) flag == 1 flag 1 U.add(e) U.add U add e print(len(U)) print len(U) len U P = [1] [1] P b = set([1,B]) set([1,B]) b flag = 0 0 flag A, B = map(int,input().split()) map(int,input().split()) A B = map(int,input().split()) map(int,input().split()) B U = set([]) set([]) U flag = 1 1 flag P += list(a&b) list(a&b) P a = set([1,A]) set([1,A]) a def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b) def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b) gcd
A, B = map(int,input().split())
P = [1]
a = set([1,A])
b = set([1,B])
for k in range(2,2+int(max(A,B)**(1/2))):
    if A%k == 0 and B%k == 0:
        P.append(k)
        a.add(A//k)
        b.add(B//k)
    elif A%k == 0:
        a.add(A//k)
    elif B%k == 0:
        b.add(B//k)

P += list(a&b)
P.sort()
U = set([])
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
for e in P:
    flag = 1
    for used in U:
        if gcd(e,used) != 1:
            flag = 0
            break
    if flag == 1:
        U.add(e)
print(len(U))
