def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, min([A, B])+1):
        if A % i == 0 and B % i == 0:
            v.append(i)
    print(v[-K])


if __name__ == '__main__':
    main() def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, min([A, B])+1):
        if A % i == 0 and B % i == 0:
            v.append(i)
    print(v[-K]) main A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K v = [] v [] for i in range(1, min([A, B])+1):
        if A % i == 0 and B % i == 0:
            v.append(i)
     i range(1, min([A, B])+1) range 1 min([A, B])+1 min([A, B]) min [A, B] A B 1 if A % i == 0 and B % i == 0:
            v.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 v.append(i) v.append v append i print(v[-K]) print v[-K] v -K K if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, min([A, B])+1):
        if A % i == 0 and B % i == 0:
            v.append(i)
    print(v[-K]) def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, min([A, B])+1):
        if A % i == 0 and B % i == 0:
            v.append(i)
    print(v[-K]) main
def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, min([A, B])+1):
        if A % i == 0 and B % i == 0:
            v.append(i)
    print(v[-K])


if __name__ == '__main__':
    main()
