def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k])

if __name__ == '__main__':
    abc120_b() def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k]) abc120_b a, b, k = map(int, input().split(' ')) a map(int, input().split(' ')) map int input().split(' ') ().split () input split ' ' b k n = min(a, b) n min(a, b) min a b divisors = [] divisors [] for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
     i range(1, n + 1) range 1 n + 1 n 1 if (a % i == 0) and (b % i == 0):
            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 divisors.append(i) divisors.append divisors append i print(divisors[-1 * k]) print divisors[-1 * k] divisors -1 * k -1 k if __name__ == '__main__':
    abc120_b() __name__ == '__main__' __name__ '__main__' abc120_b() abc120_b def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k]) def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k]) abc120_b
def abc120_b():
    a, b, k = map(int, input().split(' '))
    n = min(a, b)
    divisors = []

    for i in range(1, n + 1):
        if (a % i == 0) and (b % i == 0):
            divisors.append(i)
    print(divisors[-1 * k])

if __name__ == '__main__':
    abc120_b()