program jihanki
  implicit none
  integer :: i, j, n
  integer :: a, b, k
  integer :: count

  read(*,*)a,b,k
  n=min(a,b)

  i=0
  do while (i<n)
     i=i+1
     if (mod(a,i)==0 .and. mod(b,i)==0) then
        count=count+1
     end if
     if (count==k) then
        write(*,*)i
        exit
     end if
  end do
  
end program jihanki