program main
	implicit none
	integer :: A, B, K
	integer :: counter, i
	counter = 0
	read(*, *) A, B, K
	do i = min(A, B), 1, -1
		if(mod(A, i) == 0 .AND. mod(B, i) == 0) then
			counter = counter + 1
			if(counter == K) then
				write(*, *) i
				exit
			end if
		end if
	end do
end program main