let gcd m n =
  let rec doit x y =
    if y <= 0 then x
    else doit y (x mod y)
  in
  if m > n then doit m n
  else doit n m

let () =
  Scanf.scanf "%d %d\n" (fun a b -> Printf.printf "%d\n" (gcd a b))