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

    m = min(a, b)
    c = 1

    for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1


if __name__ == '__main__':
    main() def main():
    a, b, k = map(int, input().split())

    m = min(a, b)
    c = 1

    for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1 main a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k m = min(a, b) m min(a, b) min a b c = 1 c 1 for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1 i reversed(range(1, m + 1)) reversed range(1, m + 1) range 1 m + 1 m 1 if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1 a % i == 0 and b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 if c == k:
                print(i)
                exit()
            else:
                c += 1 c == k c k print(i) print i exit() exit c += 1 c 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a, b, k = map(int, input().split())

    m = min(a, b)
    c = 1

    for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1 def main():
    a, b, k = map(int, input().split())

    m = min(a, b)
    c = 1

    for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1 main
def main():
    a, b, k = map(int, input().split())

    m = min(a, b)
    c = 1

    for i in reversed(range(1, m + 1)):
        if a % i == 0 and b % i == 0:
            if c == k:
                print(i)
                exit()
            else:
                c += 1


if __name__ == '__main__':
    main()
