Program ABC120A

integer a,b,k,i,j,c

read(*,*) a,b,k

if (a>=b) then
 i=b
 else
 i=a
end if

c=0

do j=i,1,-1
 if (mod(a,j)==0.and.mod(b,j)==0) then
  c=c+1
  if (c==k) then
   go to 10
  end if
 end if
end do

10 write(*,*) j

stop
end