def divisor(number)
  counter = 1
  divisor = []
  while(counter <= number)
    if(number%counter == 0)
      divisor << counter
    end
    counter += 1
  end
  return divisor
end

def common_divisor(array)
  x = divisor(array[0])
  y = divisor(array[1])
  common_divisor = 0
  for i in 0..x.length-1
    for j in 0..y.length-1
      if(x[i] == y[j])
        common_divisor = x[i]
      # else
      #   puts "no common divisor"
      end
    end
  end
  puts common_divisor
end

n = gets.chomp
n = n.split().map(&:to_i)

common_divisor(n)