program main
  implicit none
  integer :: A,B,K
  integer :: ic
  integer :: i,j
  integer :: n
  
  read (*,*) A,B,K

  ic = min(A,B)
  n=0
  do  i = ic,1,-1
     if ( mod(A,i) == 0 .and. mod(B,i) == 0) then
        n = n+1
     end if
     if (n == K) then
        write(*,'(i0)') i
        stop  
     end if
  end do
  
end program main