def main():
    A, B, K = map(int, input().split())
    cnt = 0
    ans = 0

    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

    print(ans)


if __name__ == "__main__":
    main() def main():
    A, B, K = map(int, input().split())
    cnt = 0
    ans = 0

    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

    print(ans) main A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K cnt = 0 cnt 0 ans = 0 ans 0 for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

     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
         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:
            ans = i
            break

     cnt == K cnt K ans = i ans i break print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    A, B, K = map(int, input().split())
    cnt = 0
    ans = 0

    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

    print(ans) def main():
    A, B, K = map(int, input().split())
    cnt = 0
    ans = 0

    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

    print(ans) main
def main():
    A, B, K = map(int, input().split())
    cnt = 0
    ans = 0

    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
        if cnt == K:
            ans = i
            break

    print(ans)


if __name__ == "__main__":
    main()
