open System

let A,B,K=stdin.ReadLine().Split()|>fun c -> int c.[0],int c.[1],int c.[2]

[<EntryPoint>]
let main argv =
    [for i in [1..100] do yield (if (A%i=0)&&(B%i=0) then i else -1)]
    |>List.sortDescending
    |>fun l -> l.[K-1]
    |>printfn "%d"
    0