let calc a b =
  let rec iter i =
    if i > 100 then
      []
    else if a mod i == 0 && b mod i == 0 then
      i :: iter (i + 1)
    else iter (i + 1)
  in iter 1
let () =
  let (a, b, k) = Scanf.scanf "%d %d %d" (fun a b k -> (a, b, k)) in
  let l = calc a b in
  (*List.iter (fun e -> e |> string_of_int |> print_endline) l*)
  List.nth l (k - 1) |> string_of_int |> print_endline

