program main
  implicit none
  integer :: a, b, k, i, j
  read (*, *) a, b, k
  j = 0
  do i = min(a, b), 1, -1
    if (modulo(a, i) + modulo(b, i) == 0) then
      j = j + 1
      if (j == k) then
        write (*, "(i0)") i
        stop
      end if
    end if
  end do
  stop 1
end program main
