from collections import Counter
a,b=map(int,input().split())
def p_fact(n):
  m=n
  i=2
  a=[1]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
af,bf=p_fact(a),p_fact(b)
da,db={},{}
for i in af:
  if da.get(i):da[i]+=1
  else:da[i]=1
for i in bf:
  if db.get(i):db[i]+=1
  else:db[i]=1
dc={}
for i in da:
  if db.get(i):dc[i]=min(da[i],db[i])
print(len(dc)) from collections import Counter a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b def p_fact(n):
  m=n
  i=2
  a=[1]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a p_fact m=n m n i=2 i 2 a=[1] a [1] 1 while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
   n>1 n 1 if i>m**.5:
      a+=[n]
      break
     i>m**.5 i m**.5 m .5 a+=[n] a [n] n break if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
   n%i==0 n%i n i 0 n//=i n i a+=[i] a [i] i return a a n n af,bf=p_fact(a),p_fact(b) af p_fact(a) p_fact a bf p_fact(b) p_fact b da,db={},{} da {} db {} for i in af:
  if da.get(i):da[i]+=1
  else:da[i]=1 i af if da.get(i):da[i]+=1
  else:da[i]=1 da.get(i) da.get da get i for i in bf:
  if db.get(i):db[i]+=1
  else:db[i]=1 i bf if db.get(i):db[i]+=1
  else:db[i]=1 db.get(i) db.get db get i dc={} dc {} for i in da:
  if db.get(i):dc[i]=min(da[i],db[i]) i da if db.get(i):dc[i]=min(da[i],db[i db.get(i) db.get db get i print(len(dc)) print len(dc) len dc dc={} {} dc da,db={},{} {} da db={},{} {} db b=map(int,input().split()) map(int,input().split()) b af,bf=p_fact(a),p_fact(b) p_fact(a) af bf=p_fact(a),p_fact(b) p_fact(b) bf a,b=map(int,input().split()) map(int,input().split()) a def p_fact(n):
  m=n
  i=2
  a=[1]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a def p_fact(n):
  m=n
  i=2
  a=[1]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a p_fact
from collections import Counter
a,b=map(int,input().split())
def p_fact(n):
  m=n
  i=2
  a=[1]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
af,bf=p_fact(a),p_fact(b)
da,db={},{}
for i in af:
  if da.get(i):da[i]+=1
  else:da[i]=1
for i in bf:
  if db.get(i):db[i]+=1
  else:db[i]=1
dc={}
for i in da:
  if db.get(i):dc[i]=min(da[i],db[i])
print(len(dc))