import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b, k = map(int, input().split())
    cnt = 0
    for i in range(min(a,b), 0, -1):
        if a%i==0 and b%i==0:
            cnt += 1
        if cnt == k:
            print(i)
            return
        
if __name__ == '__main__':
    main() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    a, b, k = map(int, input().split())
    cnt = 0
    for i in range(min(a,b), 0, -1):
        if a%i==0 and b%i==0:
            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(min(a,b), 0, -1):
        if a%i==0 and b%i==0:
            cnt += 1
        if cnt == k:
            print(i)
            return
         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:
            print(i)
            return
         cnt == k cnt k print(i) print i return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input def main():
    a, b, k = map(int, input().split())
    cnt = 0
    for i in range(min(a,b), 0, -1):
        if a%i==0 and b%i==0:
            cnt += 1
        if cnt == k:
            print(i)
            return
         def main():
    a, b, k = map(int, input().split())
    cnt = 0
    for i in range(min(a,b), 0, -1):
        if a%i==0 and b%i==0:
            cnt += 1
        if cnt == k:
            print(i)
            return
         main
import sys
input = lambda: sys.stdin.readline().rstrip()

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