def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1]


def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K]


if __name__ == "__main__":
    print(main()) def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1] make_divisors lower_divs = [] lower_divs [] upper_divs = [] upper_divs [] i = 1 i 1 while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
     i**2 <= n i**2 i 2 n if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
         n % i == 0 n % i n i 0 lower_divs.append(i) lower_divs.append lower_divs append i if i != n // i:
                upper_divs.append(n//i)
         i != n // i i n // i n i upper_divs.append(n//i) upper_divs.append upper_divs append n//i n i i += 1 i 1 return lower_divs+upper_divs[::-1] lower_divs+upper_divs[::-1] lower_divs upper_divs[::-1] upper_divs ::-1 -1 n: int n def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K] main int(i) for i in input().strip().split() for i in input().strip().split() i input().strip().split() ().strip().split ().strip() ().strip () input strip split for i in input().strip().split() int(i) int i A, B, K = [int(i) for i in input().strip().split()] A [int(i) for i in input().strip().split()] B K div_A = set(make_divisors(A)) div_A set(make_divisors(A)) set make_divisors(A) make_divisors A div_B = set(make_divisors(B)) div_B set(make_divisors(B)) set make_divisors(B) make_divisors B common = div_A.intersection(div_B) common div_A.intersection(div_B) div_A.intersection div_A intersection div_B return sorted(list(common))[-K] sorted(list(common))[-K] (list(common)) sorted list(common) list common -K K if __name__ == "__main__":
    print(main()) __name__ == "__main__" __name__ "__main__" print(main()) print main() main def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1] def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1] make_divisors def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K] def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K] main
def make_divisors(n: int):
    lower_divs = []
    upper_divs = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            lower_divs.append(i)
            if i != n // i:
                upper_divs.append(n//i)
        i += 1
    return lower_divs+upper_divs[::-1]


def main():
    A, B, K = [int(i) for i in input().strip().split()]
    div_A = set(make_divisors(A))
    div_B = set(make_divisors(B))
    common = div_A.intersection(div_B)

    return sorted(list(common))[-K]


if __name__ == "__main__":
    print(main())
