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



arr = []

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

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

        arr.append(i)



print((arr[-k]))

import sys

stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)



i_i = lambda: int(i_s())

i_l = lambda: list(map(int, stdin.readline().split()))

i_s = lambda: stdin.readline().rstrip()



A, B, K = i_l()



arr = []

for i in range(1, min(A, B)+1):

    if A % i == 0 and B % i == 0:

        arr.append(i)



print((arr[::-1][K-1]))

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

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**7)
i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()
A, B, K = i_l()
arr = []
for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        arr.append(i)
print((arr[::-1][K - 1]))

-a, b, k = list(map(int, input().split())) +import sys + +stdin = sys.stdin +sys.setrecursionlimit(10**7) +i_i = lambda: int(i_s()) +i_l = lambda: list(map(int, stdin.readline().split())) +i_s = lambda: stdin.readline().rstrip() +A, B, K = i_l() -for i in range(1, min(a, b) + 1): -    if a % i == 0 and b % i == 0: +for i in range(1, min(A, B) + 1): +    if A % i == 0 and B % i == 0: -print((arr[-k])) +print((arr[::-1][K - 1]))