from math import*
A,B=sorted(map(int,input().split()))
prime=[]
i=1
while i**2<=A:
    if A%i==0:
        prime.append(i)
        prime.append(A//i)
    i+=1

prime=list(set(prime))
prime.sort()
L=len(prime)
ans=[1]*L
j=1
while j<L:
    now=prime[j]
    if B%now:
        ans[j]=0
    if ans[j]==0:
        j+=1
        continue
    k=j+1
    while k<L:
        if prime[k]%now==0:
            ans[k]=0
        k+=1
    j+=1

print(sum(ans)) from math import* A,B=sorted(map(int,input().split())) A sorted(map(int,input().split())) sorted map(int,input().split()) map int input().split() ().split () input split B prime=[] prime [] i=1 i 1 while i**2<=A:
    if A%i==0:
        prime.append(i)
        prime.append(A//i)
    i+=1 i**2<=A i**2 i 2 A if A%i==0:
        prime.append(i)
        prime.append(A//i)
     A%i==0 A%i A i 0 prime.append(i) prime.append prime append i prime.append(A//i) prime.append prime append A//i A i i+=1 i 1 prime=list(set(prime)) prime list(set(prime)) list set(prime) set prime prime.sort() prime.sort prime sort L=len(prime) L len(prime) len prime ans=[1]*L ans [1]*L [1] 1 L j=1 j 1 while j<L:
    now=prime[j]
    if B%now:
        ans[j]=0
    if ans[j]==0:
        j+=1
        continue
    k=j+1
    while k<L:
        if prime[k]%now==0:
            ans[k]=0
        k+=1
    j+=1 j<L j L now=prime[j] now prime[j] prime j if B%now:
        ans[j]=0
     B%now B now ans[j]=0 ans[j] ans j 0 if ans[j]==0:
        j+=1
        continue
     ans[j]==0 ans[j] ans j 0 j+=1 j 1 continue k=j+1 k j+1 j 1 while k<L:
        if prime[k]%now==0:
            ans[k]=0
        k+=1
     k<L k L if prime[k]%now==0:
            ans[k]=0
         prime[k]%now==0 prime[k]%now prime[k] prime k now 0 ans[k]=0 ans[k] ans k 0 k+=1 k 1 j+=1 j 1 print(sum(ans)) print sum(ans) sum ans i=1 1 i j+=1 1 j B=sorted(map(int,input().split())) sorted(map(int,input().split())) B k+=1 1 k k=j+1 j+1 k j+=1 1 j prime=list(set(prime)) list(set(prime)) prime ans=[1]*L [1]*L ans prime=[] [] prime now=prime[j] prime[j] now i+=1 1 i L=len(prime) len(prime) L j=1 1 j A,B=sorted(map(int,input().split())) sorted(map(int,input().split())) A
from math import*
A,B=sorted(map(int,input().split()))
prime=[]
i=1
while i**2<=A:
    if A%i==0:
        prime.append(i)
        prime.append(A//i)
    i+=1

prime=list(set(prime))
prime.sort()
L=len(prime)
ans=[1]*L
j=1
while j<L:
    now=prime[j]
    if B%now:
        ans[j]=0
    if ans[j]==0:
        j+=1
        continue
    k=j+1
    while k<L:
        if prime[k]%now==0:
            ans[k]=0
        k+=1
    j+=1

print(sum(ans))