def geta(n=0)
  return $stdin.gets.to_i if n==0
  ar = []
  n.times do 
    ar << $stdin.gets.chomp.split
  end
  return ar.flatten(1) if n<=1
  return ar
end

@ar = geta(1).map(&:to_i)
y,x = @ar.sort

rems = [y]
while (rem=x%y)>0
  rems << rem
  x = y
  y = rem
end

p rems.min
