def main():
    a,b,k  = map(int,input().split())
    ans = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            ans.append(i)
    print(ans[-k])


if __name__ == '__main__':
    main() def main():
    a,b,k  = map(int,input().split())
    ans = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            ans.append(i)
    print(ans[-k]) main a,b,k  = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k ans = [] ans [] for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            ans.append(i)
     i range(1,min(a,b)+1) range 1 min(a,b)+1 min(a,b) min a b 1 if a % i == 0 and b % i == 0:
            ans.append(i)
     a % i == 0 and b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 ans.append(i) ans.append ans append i print(ans[-k]) print ans[-k] ans -k k if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a,b,k  = map(int,input().split())
    ans = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            ans.append(i)
    print(ans[-k]) def main():
    a,b,k  = map(int,input().split())
    ans = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            ans.append(i)
    print(ans[-k]) main
def main():
    a,b,k  = map(int,input().split())
    ans = []
    for i in range(1,min(a,b)+1):
        if a % i == 0 and b % i == 0:
            ans.append(i)
    print(ans[-k])


if __name__ == '__main__':
    main()