def main():
    a, b, k = map(int,input().split())
    cnt = 0
    for i in range(max(a,b), 0, -1):
        if a % i == 0 and b % i == 0:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return

if __name__ == "__main__":
    main() def main():
    a, b, k = map(int,input().split())
    cnt = 0
    for i in range(max(a,b), 0, -1):
        if a % i == 0 and b % i == 0:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return 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 for i in range(max(a,b), 0, -1):
        if a % i == 0 and b % i == 0:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return i range(max(a,b), 0, -1) range max(a,b) max a b 0 -1 if a % i == 0 and b % i == 0:
            #print(i)
            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 = map(int,input().split())
    cnt = 0
    for i in range(max(a,b), 0, -1):
        if a % i == 0 and b % i == 0:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return def main():
    a, b, k = map(int,input().split())
    cnt = 0
    for i in range(max(a,b), 0, -1):
        if a % i == 0 and b % i == 0:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return main
def main():
    a, b, k = map(int,input().split())
    cnt = 0
    for i in range(max(a,b), 0, -1):
        if a % i == 0 and b % i == 0:
            #print(i)
            cnt += 1
            if cnt == k:
                print(i)
                return

if __name__ == "__main__":
    main()