let () =
  Scanf.scanf "%d %d %d" @@ fun a b k ->
  let rec f c i =
    if c = k then i+1
    else if a mod i = 0 && b mod i = 0 then f (c+1) (i-1)
    else f c (i-1)
  in f 0 (min a b) |> Printf.printf "%d\n"
