def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

    for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

    return common_divisors[-k]

a, b, k = map(int, input().split())
print(actual(a, b, k)) def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

    for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

    return common_divisors[-k] actual M = max(a, b) M max(a, b) max a b common_divisors = [] common_divisors [] for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

     i range(1, M + 1) range 1 M + 1 M 1 if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

     (a % i == 0) and (b % i == 0) a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 common_divisors.append(i) common_divisors.append common_divisors append i return common_divisors[-k] common_divisors[-k] common_divisors -k k a a b b k k a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k print(actual(a, b, k)) print actual(a, b, k) actual a b k k = map(int, input().split()) map(int, input().split()) k a, b, k = map(int, input().split()) map(int, input().split()) a def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

    for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

    return common_divisors[-k] def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

    for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

    return common_divisors[-k] actual b, k = map(int, input().split()) map(int, input().split()) b
def actual(a, b, k):
    M = max(a, b)

    common_divisors = []

    for i in range(1, M + 1):
        if (a % i == 0) and (b % i == 0):
            common_divisors.append(i)

    return common_divisors[-k]

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