#!/usr/bin/env ruby
# require 'pry'

# N
# a_1 b_1
# ...
# a_N b_N
# ↑を[[a_1,..a_N],[b_1,..b_N]]にする
# N = gets.to_i
# a, b = N.times.map{gets.split.map(&:to_i)}.transpose

a,b,k = gets.split.map &:to_i
ary=[*(1..100)].reverse!
ary2 = ary.map do |e|
  e if a % e == 0 && b % e == 0
end.compact!

puts ary2[k-1]