import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


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

    print(C[-K])

if __name__ == '__main__':
    main() import sys sys import math math read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline INF = float('inf') INF float('inf') float 'inf' def main():
    A, B, K = map(int, readline().split())
    C = []
    for i in range(1,min(A,B)+1):
        if A%i==0 and B%i==0:
            C.append(i)

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

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

    print(C[-K]) main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline read = sys.stdin.read sys.stdin.read read INF = float('inf') float('inf') INF
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


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

    print(C[-K])

if __name__ == '__main__':
    main()
