a,b = gets.chomp.split.map(&:to_i)
if a == b
    only = a
elsif a > b
    large = a
    small = b
else
    large = b
    small = a
end
while small > 0
    large, small = small, large%small
end
if large == 1
    puts 1
    exit
end

com_div =[]
1.upto(large) do |i|
    if small%i == 0 && large%i == 0
        com_div.push(i)
    end
end

1.upto(com_div.length-1) do |i|
    delete_list = []
    break if com_div[-1*i] == nil
    (i+1).upto(com_div.length-1) do |j|
        if com_div[j] % com_div[i] == 0
            delete_list.push(com_div[j])
        end
    end
    delete_list.each{|num| com_div.delete(num)}
end

p com_div.length