[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main argv =
    let [a;b;k] = reads int
    seq {
        for i in 100 .. -1 .. 1 do
            if a % i = 0 && b % i = 0 then yield i
    }
    |> Seq.item (k - 1)
    |> printfn "%i"
    0