input_line = gets

x = input_line.split(" ")[0].to_i
y = input_line.split(" ")[1].to_i

def gcd_check(list1,list2)
  gcd = []
  list1 = list1.sort;list2 = list2.sort;
  list1.each do |item|
    gcd << item if list2.include?(item)
  end
  p gcd.max
end

def common_div(x)
  list = []
  1.upto(x) do |i|
    if (x % i) == 0
      list << (x / i)
    end
  end
  return list
end

x_list = common_div(x)
y_list = common_div(y)

gcd_check(x_list,y_list)