implicit none
 
 integer a,b,k,less,i
  integer :: counts=0
    
  read(5,*)a,b,k
  
  if(a>=b) then
    less=b
  else
    less=a
endif  

  do i=1,less
  
  if(mod(a,i).eq.0 .and. mod(b,i).eq.0) then
    counts=counts+1
  
if(counts.ge.k) then
   write(6,*) i
    exit
  endif

endif
  
 enddo

end

