from typing import Set


def divisors(n: int) -> Set[int]:
    divs = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
    return divs


def answer(a: int, b: int, k: int) -> int:
    divisors_a = divisors(a)
    divisors_b = divisors(b)

    common_divisors = list(divisors_a & divisors_b)
    common_divisors.sort()

    return common_divisors[-k]


def main():
    a, b, k = map(int, input().split())
    print(answer(a, b, k))


if __name__ == '__main__':
    main() from typing import Set def divisors(n: int) -> Set[int]:
    divs = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
    return divs divisors divs = set() divs set() set i = 1 i 1 while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
     i * i <= n i * i i i n if n % i == 0:
            divs.add(i)
            divs.add(n // i)
         n % i == 0 n % i n i 0 divs.add(i) divs.add divs add i divs.add(n // i) divs.add divs add n // i n i i += 1 i 1 return divs divs n: int n def answer(a: int, b: int, k: int) -> int:
    divisors_a = divisors(a)
    divisors_b = divisors(b)

    common_divisors = list(divisors_a & divisors_b)
    common_divisors.sort()

    return common_divisors[-k] answer divisors_a = divisors(a) divisors_a divisors(a) divisors a divisors_b = divisors(b) divisors_b divisors(b) divisors b common_divisors = list(divisors_a & divisors_b) common_divisors list(divisors_a & divisors_b) list divisors_a & divisors_b divisors_a divisors_b common_divisors.sort() common_divisors.sort common_divisors sort return common_divisors[-k] common_divisors[-k] common_divisors -k k a: int a b: int b k: int k def main():
    a, b, k = map(int, input().split())
    print(answer(a, b, k)) main a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k print(answer(a, b, k)) print answer(a, b, k) answer a b k if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a, b, k = map(int, input().split())
    print(answer(a, b, k)) def main():
    a, b, k = map(int, input().split())
    print(answer(a, b, k)) main def divisors(n: int) -> Set[int]:
    divs = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
    return divs def divisors(n: int) -> Set[int]:
    divs = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
    return divs divisors def answer(a: int, b: int, k: int) -> int:
    divisors_a = divisors(a)
    divisors_b = divisors(b)

    common_divisors = list(divisors_a & divisors_b)
    common_divisors.sort()

    return common_divisors[-k] def answer(a: int, b: int, k: int) -> int:
    divisors_a = divisors(a)
    divisors_b = divisors(b)

    common_divisors = list(divisors_a & divisors_b)
    common_divisors.sort()

    return common_divisors[-k] answer
from typing import Set


def divisors(n: int) -> Set[int]:
    divs = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            divs.add(i)
            divs.add(n // i)
        i += 1
    return divs


def answer(a: int, b: int, k: int) -> int:
    divisors_a = divisors(a)
    divisors_b = divisors(b)

    common_divisors = list(divisors_a & divisors_b)
    common_divisors.sort()

    return common_divisors[-k]


def main():
    a, b, k = map(int, input().split())
    print(answer(a, b, k))


if __name__ == '__main__':
    main()
