x, y = gets.chomp.split.map(&:to_i)

if x > y
   rest = x % y
   y_common_divisors = Array.new
   for i in 1..y do
      y_common_divisors.push i if y % i == 0
   end
   x_y_common_divisors = Array.new
   for i in 1..rest do
      x_y_common_divisors.push i if rest % i == 0
   end

   common_divisors = y_common_divisors & x_y_common_divisors
   puts common_divisors[common_divisors.count - 1]
elsif x < y
   rest = y % x
   x_common_divisors = Array.new
   for i in 1..x do
      x_common_divisors.push i if x % i == 0
   end
   x_y_common_divisors = Array.new
   for i in 1..rest do
      x_y_common_divisors.push i if rest % i == 0
   end

   common_divisors = x_common_divisors & x_y_common_divisors
   puts common_divisors[common_divisors.count - 1]
elsif x = y
   puts x
end