let () = Scanf.scanf "%d %d %d" @@ fun a b k ->
  let rec loop i count =
    let cond = a mod i = 0 && b mod i = 0 in
    match (cond, (count = k - 1)) with
    | (true, true) -> i
    | (true, false) -> loop (i - 1) (count + 1)
    | _ -> loop (i - 1) count
  in
  let ans = loop a 0 in
  Printf.printf "%d\n" ans