import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num)


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline in_n = lambda: int(readline()) in_n lambda: int(readline()) int(readline()) int readline() readline in_nn = lambda: map(int, readline().split()) in_nn lambda: map(int, readline().split()) map(int, readline().split()) map int readline().split() ().split () readline split in_s = lambda: readline().rstrip().decode('utf-8') in_s lambda: readline().rstrip().decode('utf-8') readline().rstrip().decode('utf-8') ().rstrip().decode ().rstrip() ().rstrip () readline rstrip decode 'utf-8' def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num) main A, B, K = in_nn() A in_nn() in_nn B K count = 0 count 0 num = min(A, B) + 1 num min(A, B) + 1 min(A, B) min A B 1 while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

     count < K count K num -= 1 num 1 if A % num == 0 and B % num == 0:
            count += 1

     A % num == 0 and B % num == 0 A % num == 0 A % num A num 0 B % num == 0 B % num B num 0 count += 1 count 1 print(num) print num if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.buffer.read sys.stdin.buffer.read read readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline in_n = lambda: int(readline()) lambda: int(readline()) in_n in_s = lambda: readline().rstrip().decode('utf-8') lambda: readline().rstrip().decode('utf-8') in_s in_nn = lambda: map(int, readline().split()) lambda: map(int, readline().split()) in_nn def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num) def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num) main
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    A, B, K = in_nn()

    count = 0
    num = min(A, B) + 1
    while count < K:
        num -= 1
        if A % num == 0 and B % num == 0:
            count += 1

    print(num)


if __name__ == '__main__':
    main()
