#nowarn "25"

open System.Linq
open System.Text.RegularExpressions

let input() = stdin.ReadLine()
let inputs() = input().Split()
let inInt() = int (input())
let readIntArr() = inputs() |> Array.map int

let YN b = printfn "%s" (if b then "Yes" else "No")
let print x = printfn "%A" x
let printS (s: string) = printfn "%s" s



let [| A; B; K |] = readIntArr()

let CommonDivisor =
    query {
        for k in [ 100 .. -1 .. 1 ] do
            where (A % k = 0 && B % k = 0)
    }
    |> Array.ofSeq

print CommonDivisor.[K - 1]
