let rec solve cur a b k =
  if a mod cur == 0 && b mod cur = 0 then 
    begin
      if k <= 1 then cur
      else solve (cur - 1) a b (k - 1)
    end
  else solve (cur - 1) a b k

let solve a b k = solve (min a b) a b k

let _ =
  let a, b, k = Scanf.scanf "%d %d %d" (fun a b k -> (a, b, k)) in
  solve a b k
  |> print_int