program main
  implicit none
  integer :: a, b, k, i, j = 0
  
  read *, a, b, k

  do i = min(a, b), 1, -1
    j = j + 1
    if (mod(a, i) + mod(b, i) > 0) then
      j = j - 1
    end if
    if (j == k) then
      print '(i0)', i
      exit
    end if
  end do

end