def mi():
    return map(int, input().split())

def main():
    A, B, K = mi()
    cnt = 0
    for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return

if __name__ == '__main__':
    main() def mi():
    return map(int, input().split()) mi return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def main():
    A, B, K = mi()
    cnt = 0
    for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return main A, B, K = mi() A mi() mi B K cnt = 0 cnt 0 for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return i range(min(A, B), 0, -1) range min(A, B) min A B 0 -1 if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return A%i == 0 and B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 cnt += 1 cnt 1 if cnt == K:
                print(i)
                return cnt == K cnt K print(i) print i return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    A, B, K = mi()
    cnt = 0
    for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return def main():
    A, B, K = mi()
    cnt = 0
    for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return main def mi():
    return map(int, input().split()) def mi():
    return map(int, input().split()) mi
def mi():
    return map(int, input().split())

def main():
    A, B, K = mi()
    cnt = 0
    for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return

if __name__ == '__main__':
    main()