a,b=gets.split(" ").map(&:to_i)
copr=[]
gcd=a.gcd(b)
i=1
while i<=gcd
  if a%i==0 and b%i==0
  copr << i
  end
  i+=1
end
n=0
i=1
while i<copr.length
  copr.reject!{|e| e%copr[i]==0 && e>copr[i]}
  if copr[i+1].nil?
    break
  end
  i+=1
#puts copr.join(" ")
end
puts copr.length