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

def prime_factorization(n):
    arr=[]
    temp=n

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

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

setA=set(prime_factorization(A))
setB=set(prime_factorization(B))
setAB=setA &setB
if setAB=={1}:
    print(1)
else:
    print(len(setAB)+1) A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B def prime_factorization(n):
    arr=[]
    temp=n

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

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

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

     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) arr.append arr append i if temp!=1:
        arr.append(temp)
    
     temp!=1 temp 1 arr.append(temp) arr.append arr append temp if arr==[]:
        arr.append(n)
    
     arr==[] arr [] arr.append(n) arr.append arr append n return arr arr n n setA=set(prime_factorization(A)) setA set(prime_factorization(A)) set prime_factorization(A) prime_factorization A setB=set(prime_factorization(B)) setB set(prime_factorization(B)) set prime_factorization(B) prime_factorization B setAB=setA &setB setAB setA &setB setA setB if setAB=={1}:
    print(1)
else:
    print(len(setAB)+1) setAB=={1} setAB {1} print(1) print 1 print(len(setAB)+1) print len(setAB)+1 len(setAB) len setAB 1 B=map(int,input().split()) map(int,input().split()) B A,B=map(int,input().split()) map(int,input().split()) A setB=set(prime_factorization(B)) set(prime_factorization(B)) setB def prime_factorization(n):
    arr=[]
    temp=n

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

    if temp!=1:
        arr.append(temp)
    
    if arr==[]:
        arr.append(n)
    
    return arr def prime_factorization(n):
    arr=[]
    temp=n

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

    if temp!=1:
        arr.append(temp)
    
    if arr==[]:
        arr.append(n)
    
    return arr prime_factorization setAB=setA &setB setA &setB setAB setA=set(prime_factorization(A)) set(prime_factorization(A)) setA
A,B=map(int,input().split())

def prime_factorization(n):
    arr=[]
    temp=n

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

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

setA=set(prime_factorization(A))
setB=set(prime_factorization(B))
setAB=setA &setB
if setAB=={1}:
    print(1)
else:
    print(len(setAB)+1)