let [|a;b;k|] = stdin.ReadLine().Split() |> Array.map int

let m = List.min [a;b]

seq {
  for i in List.rev [1..m] do
    if a % i = 0 && b % i = 0 then
      yield i
}
|> Seq.take k
|> Seq.last
|> printfn "%d"