a,b = gets.chomp.split(" ").map{|i|i = i.to_i}

minn=nil
maxx=nil
arr=[]
if a<b then
  minn=a
  maxx=b
else
  minn=b
  maxx=a
end
minn.times{|i|
  if(minn % (i+1)==0 && maxx % (i+1) == 0)
    arr<<i+1
  end
}
#pp arr

answer=[]
i=0
while true
  
  i+=1
  if arr.length <= i
    break
  end
  elm=arr[i]
  flag=1
  j=i
  #puts "arr.length = #{arr.length}"
  while true

    if flag==0 
      flag=1
    else
      j += 1
    end
    
    if arr.length <= j
      break
    end
    #puts "now j = #{j}"
    if (arr[j] % elm==0) then # もし割り切れたら消す
      #puts "== delete arr[#{j}] (= #{arr[j]} ) == "
      arr.delete_at(j)
      flag=0
    else
      flag=1
    end
  end
  #puts "================\n now arr = #{arr}\n=============================="
end
#puts "final arr : #{arr}"
puts arr.length