A,B=map(int,input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
a=make_divisors(A)
b=make_divisors(B)
kouyakusuu=set(a)&set(b)
out=[]
kouho=sorted(list(kouyakusuu))
del kouho[0]
for a in range(len(kouho)-1):
    for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b])
answer=set(out)
print(len(kouho)+1-len(answer)) A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors , upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
     i*i <= n i*i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n a=make_divisors(A) a make_divisors(A) make_divisors A b=make_divisors(B) b make_divisors(B) make_divisors B kouyakusuu=set(a)&set(b) kouyakusuu set(a)&set(b) set(a) set a set(b) set b out=[] out [] kouho=sorted(list(kouyakusuu)) kouho sorted(list(kouyakusuu)) sorted list(kouyakusuu) list kouyakusuu del kouho[0] kouho[0] kouho 0 for a in range(len(kouho)-1):
    for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b]) a range(len(kouho)-1) range len(kouho)-1 len(kouho) len kouho 1 for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b]) b range(a+1,len(kouho)) range a+1 a 1 len(kouho) len kouho if kouho[b]%kouho[a]==0:
            out.append(kouho[b]) kouho[b]%kouho[a]==0 kouho[b]%kouho[a] kouho[b] kouho b kouho[a] kouho a 0 out.append(kouho[b]) out.append out append kouho[b] kouho b answer=set(out) answer set(out) set out print(len(kouho)+1-len(answer)) print len(kouho)+1-len(answer) len(kouho)+1 len(kouho) len kouho 1 len(answer) len answer a=make_divisors(A) make_divisors(A) a b=make_divisors(B) make_divisors(B) b kouho=sorted(list(kouyakusuu)) sorted(list(kouyakusuu)) kouho B=map(int,input().split()) map(int,input().split()) B kouyakusuu=set(a)&set(b) set(a)&set(b) kouyakusuu answer=set(out) set(out) answer A,B=map(int,input().split()) map(int,input().split()) A def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors out=[] [] out
A,B=map(int,input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
a=make_divisors(A)
b=make_divisors(B)
kouyakusuu=set(a)&set(b)
out=[]
kouho=sorted(list(kouyakusuu))
del kouho[0]
for a in range(len(kouho)-1):
    for b in range(a+1,len(kouho)):
        if kouho[b]%kouho[a]==0:
            out.append(kouho[b])
answer=set(out)
print(len(kouho)+1-len(answer))
