program main
   implicit none
   integer(8)::a,b,k,cou=0
   integer(8)::i,j
   
  ! integer,allocatable,dimension(:)::c
   read(*,*)a,b,k
   do i=min(a,b),1,-1
      
      if(mod(a,i)==0 .and. mod(b,i)==0)then
         cou=cou+1
         if(cou==k)exit
      endif
   enddo
   write(*,*)i
end program main
