let a, b, k = stdin.ReadLine().Split() |> fun x -> int x.[0], int x.[1], int x.[2]
let c = [for i in 1..a -> if a % i = 0 then i else 1] |> List.distinct |> Set.ofList
let d = [for i in 1..b -> if b % i = 0 then i else 1] |> List.distinct |> Set.ofList
let f = Set.union c d |> Set.toList
printfn "%d" f.[k - 1]