program main
    implicit none

    integer A,B,K,i,count
    count = 0

    read(*,*) A,B,K

    do i = max(A,B),1
        if (mod(A,i)==0 .and. mod(B,i)==0)then
            count = count + 1
            if (count == K) then
                write(*,"(I0)") i
                exit 
            end if
        end if
    enddo

end program main