from fractions import gcd


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


A, B, K = map(int, input().split())
a = gcd(A, B)
Ans = make_divisors(a)

print(Ans[K-1]) from fractions import gcd def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors make_divisors divisors = [] divisors [] for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

     i range(1, int(n**0.5)+1) range 1 int(n**0.5)+1 int(n**0.5) int n**0.5 n 0.5 1 if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

     n % i == 0 n % i n i 0 divisors.append(i) divisors.append divisors append i if i != n // i:
                divisors.append(n//i)

     i != n // i i n // i n i divisors.append(n//i) divisors.append divisors append n//i n i divisors.sort(reverse=True) divisors.sort divisors sort reverse=True reverse True return divisors divisors n n A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K a = gcd(A, B) a gcd(A, B) gcd A B Ans = make_divisors(a) Ans make_divisors(a) make_divisors a print(Ans[K-1]) print Ans[K-1] Ans K-1 K 1 a = gcd(A, B) gcd(A, B) a Ans = make_divisors(a) make_divisors(a) Ans K = map(int, input().split()) map(int, input().split()) K A, B, K = map(int, input().split()) map(int, input().split()) A def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors make_divisors B, K = map(int, input().split()) map(int, input().split()) B
from fractions import gcd


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


A, B, K = map(int, input().split())
a = gcd(A, B)
Ans = make_divisors(a)

print(Ans[K-1])