import fractions as fr



A , B , K = list(map(int,input().split())) # A,B <= 100



k = 0



R = int(max(fr.gcd(A,B),1))



for i in range(R,0,-1) :

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

        k += 1

        if k >= K :

            print(i)

            break



A, B, K = list(map(int, input().split()))



ans = []

for i in range(1, 1000):

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

        ans.append(i)



ans.sort(reverse=True)

print((ans[K - 1]))

import fractions as fr

A, B, K = list(map(int, input().split()))  # A,B <= 100
k = 0
R = int(max(fr.gcd(A, B), 1))
for i in range(R, 0, -1):
    if A % i == 0 and B % i == 0:
        k += 1
        if k >= K:
            print(i)
            break

A, B, K = list(map(int, input().split()))
ans = []
for i in range(1, 1000):
    if A % i == 0 and B % i == 0:
        ans.append(i)
ans.sort(reverse=True)
print((ans[K - 1]))

-import fractions as fr - -A, B, K = list(map(int, input().split()))  # A,B <= 100 -k = 0 -R = int(max(fr.gcd(A, B), 1)) -for i in range(R, 0, -1): +A, B, K = list(map(int, input().split())) +ans = [] +for i in range(1, 1000): -        k += 1 -        if k >= K: -            print(i) -            break +        ans.append(i) +ans.sort(reverse=True) +print((ans[K - 1]))