program divv
  implicit none

  integer :: A,B,K,i,j,k1,l1,l2

  read(*,*) A,B,K
  k1=0
     if(A.eq.B) then
        write(*,'(i0)') A
        stop
     endif

if((A.eq.1).or.(B.eq.1)) then
        write(*,'(i0)') 1
        stop
     endif

  do i=1,A
!     write(*,*) (A/2)-i+1                                                                                                                                               
     l1=A-i+1
!     if(A.eq.B) then                                                                                                                                                    
!        write(*,'(i0)') A                                                                                                                                               
!        stop                                                                                                                                                            
!     endif                                                                                                                                                              

     if((mod(A,l1).eq.0).and.(mod(B,l1).eq.0)) then
        l2=l1
        k1=k1+1
        if(k1.eq.K) then
           write(*,'(i0)') l1
        endif
     endif
  enddo


end program divv


