A, B, K = map(int, input().split())
 
cnt = 0
for i in range(1, min(A, B)+1)[::-1]:
  if (A % i == 0) and (B % i == 0):
    cnt += 1
  if cnt == K:
    print(i)
    exit(0) A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K cnt = 0 cnt 0 for i in range(1, min(A, B)+1)[::-1]:
  if (A % i == 0) and (B % i == 0):
    cnt += 1
  if cnt == K:
    print(i)
    exit(0) i range(1, min(A, B)+1)[::-1] (1, min(A, B)+1) range 1 min(A, B)+1 min(A, B) min A B 1 ::-1 -1 if (A % i == 0) and (B % i == 0):
    cnt += 1
   (A % i == 0) and (B % i == 0) A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 cnt += 1 cnt 1 if cnt == K:
    print(i)
    exit(0) cnt == K cnt K print(i) print i exit(0) exit 0 cnt = 0 0 cnt A, B, K = map(int, input().split()) map(int, input().split()) A K = map(int, input().split()) map(int, input().split()) K B, K = map(int, input().split()) map(int, input().split()) B cnt += 1 1 cnt
A, B, K = map(int, input().split())
 
cnt = 0
for i in range(1, min(A, B)+1)[::-1]:
  if (A % i == 0) and (B % i == 0):
    cnt += 1
  if cnt == K:
    print(i)
    exit(0)