import sys
sys.setrecursionlimit(10**6)

a,b,k=map(int,input().split())

i=0
for j in range(max(a,b),0,-1):
    if a%j==0 and b%j==0:
        i+=1
    if i==k:
        print(j)
        exit()
 import sys sys sys.setrecursionlimit(10**6) sys.setrecursionlimit sys setrecursionlimit 10**6 10 6 a,b,k=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k i=0 i 0 for j in range(max(a,b),0,-1):
    if a%j==0 and b%j==0:
        i+=1
    if i==k:
        print(j)
        exit() j range(max(a,b),0,-1) range max(a,b) max a b 0 -1 if a%j==0 and b%j==0:
        i+=1
     a%j==0 and b%j==0 a%j==0 a%j a j 0 b%j==0 b%j b j 0 i+=1 i 1 if i==k:
        print(j)
        exit() i==k i k print(j) print j exit() exit i=0 0 i b,k=map(int,input().split()) map(int,input().split()) b k=map(int,input().split()) map(int,input().split()) k i+=1 1 i a,b,k=map(int,input().split()) map(int,input().split()) a
import sys
sys.setrecursionlimit(10**6)

a,b,k=map(int,input().split())

i=0
for j in range(max(a,b),0,-1):
    if a%j==0 and b%j==0:
        i+=1
    if i==k:
        print(j)
        exit()

