a, b, k = list(map(int, input().split()))

count = 0



for i in range(1, min(a, b)+1)[::-1]:

    if a%i==0 and b%i==0:

        count += 1

    if count == k:

        print(i)

        exit()

a,b,k = list(map(int,input().split()))

count =[]

for i in range(1,min(a,b)+1):

  if a%i == 0 and b%i == 0:

    count.append(i)

  else:

    pass



print((count[-k]))

    
a, b, k = list(map(int, input().split()))
count = 0
for i in range(1, min(a, b) + 1)[::-1]:
    if a % i == 0 and b % i == 0:
        count += 1
    if count == k:
        print(i)
        exit()

a, b, k = list(map(int, input().split()))
count = []
for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        count.append(i)
    else:
        pass
print((count[-k]))

-count = 0 -for i in range(1, min(a, b) + 1)[::-1]: +count = [] +for i in range(1, min(a, b) + 1): -        count += 1 -    if count == k: -        print(i) -        exit() +        count.append(i) +    else: +        pass +print((count[-k]))