program kt
  implicit none
  integer :: i,jun,A,B,K,tp

  read(*,*) A,B,K

  tp=min(A,B)
!  write(*,*) tp                                                                

  jun=0
  do i=tp,1,-1
!     write(*,*) i                                                              
     if((mod(A,i)==0).and.(mod(B,i)==0)) then
        jun=jun+1
     endif
     if(jun.eq.K) then
        exit
     endif
  enddo
  write(*,'(i0)') i
end program kt