require 'prime'
A, B = gets.chomp.split.map(&:to_i)


def gcd(a, b)
  a, b = b, a if a < b

  while b > 0
    a, b = b, a % b
  end
  a
end

def fetch_prime_list(max)
  table = Array.new(max + 1,true)

  (2..max).each do |num|
    if table[num] == true
      k = num * num
      while k <= max
        table[k] = false
        k += num
      end
    end
  end
  return table
end

g = gcd(A, B)
p 1 + g.prime_division.size
