let split target =
  Str.split (Str.regexp " ") target
  |> List.map int_of_string


let rec gcd x y =
  match (x, y) with
  | (_, 0) -> x
  | (_, _) -> gcd y (x mod y)


let () =
  let nums =
    read_line ()
    |> split in
  Printf.printf "%d\n" (gcd (List.nth nums 0) (List.nth nums 1))