program bbb
implicit none

integer :: a, b, k, n, res

read*, a, b, k

n=min(a,b)+1
res=0
do while(res/=k)
n=n-1
if(mod(a,n)==0.and.mod(b,n)==0) then
res=res+1
end if
end do

write(*,'(i0)') n

end program