let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let i, c = ref @@ min a b, ref 0
let _ = while !c < k do if a mod !i = 0 && b mod !i = 0 then incr c; decr i done; Printf.printf "%d\n" @@ !i + 1