def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break
main() def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break main a,b,k = list(map(int,input().split())) a list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split b k loop=0 loop 0 if a<b:
    loop=a
  else:
    loop=b
   a<b a b loop=a loop a loop=b loop b now=0 now 0 for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break i reversed(range(1,loop+1)) reversed range(1,loop+1) range 1 loop+1 loop 1 if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break a%i==0 and b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 now+=1 now 1 if now==k:
        print(i)
        break now==k now k print(i) print i break main() main def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break main
def main():
  a,b,k = list(map(int,input().split()))
  loop=0
  if a<b:
    loop=a
  else:
    loop=b
  now=0
  for i in reversed(range(1,loop+1)):
    if a%i==0 and b%i==0:
      now+=1
      if now==k:
        print(i)
        break
main()