program answer
  implicit none
  integer :: i, A, B, K, c, ans
  read(*,*) A, B, K
  call gcd(A,B,c)
  call yaku(c,K,ans)
  write(*,*) ans
  
  stop
contains
  subroutine gcd(a,b,ans)
    implicit none
    integer :: a, b, ans, c
    if(b>a) then
       c=b
       b=a
       a=c
    end if
    do
       if(mod(a,b)==0) then
          ans=b
          exit
       end if
       c=b
       b=mod(a,b)
       a=c
    end do
  end subroutine gcd

  subroutine yaku(a,k,ans)
    implicit none
    integer :: a, k, ans, i, j
    integer :: s(a)
    s=0
    j=0
    do i = a, 1, -1
       if(mod(a,i)==0) then
          j=j+1
          s(j)=i
       end if
    end do
    ans=s(k)
  end subroutine yaku
 end program answer