def min(a,b) a<b ? a:b end
A,B=gets.split.map(&:to_i)
#A,B=10**12, 10**12

n=Math.sqrt(min(A,B)).to_i

#n=min(A,B)
kou=[]
(1..n).each do |i|
  if A%i == 0 && B%i == 0
    kou << i
  end
end

ans=[]
size=kou.size
size.times do |i|
  flag=true
  size.times do |j|
    next if i == j
    next if j == 0
    if kou[i]%kou[j] == 0
      flag=false
    end
  end
  ans << kou[i] if flag
end
p ans.size