a,b,k=input().split()

a,b,k=int(a),int(b),int(k)

c=0

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

    if a%(min(a,b)-i)==0 and b%(min(a,b)-i)==0:

        #print(i+1)

        c+=1

    if c==k:

        print((min(a,b)-i))

        break

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

check=0

m=min(a,b)

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

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

        check+=1

        if check==k:

            print(i)

            break

a, b, k = input().split()
a, b, k = int(a), int(b), int(k)
c = 0
for i in range(min(a, b)):
    if a % (min(a, b) - i) == 0 and b % (min(a, b) - i) == 0:
        # print(i+1)
        c += 1
    if c == k:
        print((min(a, b) - i))
        break

a, b, k = list(map(int, input().split()))
check = 0
m = min(a, b)
for i in range(m, 0, -1):
    if a % i == 0 and b % i == 0:
        check += 1
        if check == k:
            print(i)
            break

-a, b, k = input().split() -a, b, k = int(a), int(b), int(k) -c = 0 -for i in range(min(a, b)): -    if a % (min(a, b) - i) == 0 and b % (min(a, b) - i) == 0: -        # print(i+1) -        c += 1 -    if c == k: -        print((min(a, b) - i)) -        break +a, b, k = list(map(int, input().split())) +check = 0 +m = min(a, b) +for i in range(m, 0, -1): +    if a % i == 0 and b % i == 0: +        check += 1 +        if check == k: +            print(i) +            break