import numpy as np

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()
    return divisors

if __name__ == '__main__':
    A, B, K = map(int, input().split())
    N = make_divisors(np.gcd(A, B))
    N.sort(reverse=True)
    print(N[K-1]) import numpy as np numpy 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()
    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() divisors.sort divisors sort return divisors divisors n n if __name__ == '__main__':
    A, B, K = map(int, input().split())
    N = make_divisors(np.gcd(A, B))
    N.sort(reverse=True)
    print(N[K-1]) __name__ == '__main__' __name__ '__main__' A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K N = make_divisors(np.gcd(A, B)) N make_divisors(np.gcd(A, B)) make_divisors np.gcd(A, B) np.gcd np gcd A B N.sort(reverse=True) N.sort N sort reverse=True reverse True print(N[K-1]) print N[K-1] N K-1 K 1 B, K = map(int, input().split()) map(int, input().split()) B N = make_divisors(np.gcd(A, B)) make_divisors(np.gcd(A, B)) N 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()
    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()
    return divisors make_divisors A, B, K = map(int, input().split()) map(int, input().split()) A K = map(int, input().split()) map(int, input().split()) K
import numpy as np

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()
    return divisors

if __name__ == '__main__':
    A, B, K = map(int, input().split())
    N = make_divisors(np.gcd(A, B))
    N.sort(reverse=True)
    print(N[K-1])