import fractions

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

q = fractions.gcd(a,b)

count = 0

for i in range(q,-1,-1):

    if q%i == 0:

        count += 1

        if count == k:

            print(i)

            exit()
from fractions import gcd

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

x = gcd(a,b)

now = 1

if now == k:

    print(x)

    exit()

for i in range(x-1,-1,-1):

    if x%i == 0:now += 1

    if now == k:

        print(i)

        exit()
import fractions

a, b, k = list(map(int, input().split()))
q = fractions.gcd(a, b)
count = 0
for i in range(q, -1, -1):
    if q % i == 0:
        count += 1
        if count == k:
            print(i)
            exit()

from fractions import gcd

a, b, k = list(map(int, input().split()))
x = gcd(a, b)
now = 1
if now == k:
    print(x)
    exit()
for i in range(x - 1, -1, -1):
    if x % i == 0:
        now += 1
    if now == k:
        print(i)
        exit()

-import fractions +from fractions import gcd -q = fractions.gcd(a, b) -count = 0 -for i in range(q, -1, -1): -    if q % i == 0: -        count += 1 -        if count == k: -            print(i) -            exit() +x = gcd(a, b) +now = 1 +if now == k: +    print(x) +    exit() +for i in range(x - 1, -1, -1): +    if x % i == 0: +        now += 1 +    if now == k: +        print(i) +        exit()