(* O(min {a, b}) *)
let solve a b k =
  let rec find acc n =
    if acc >= k then
      n + 1
    else
      find (if a mod n = 0 && b mod n = 0 then acc + 1 else acc) (n - 1)
  in
    find 0 (min a b)

let _ = Scanf.scanf "%d %d %d" (fun a b k -> solve a b k) |> string_of_int |> print_endline