# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
A,B,K= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
count=0
wari=min(A,B)
while True:
    if A%wari==0 and B%wari==0:
        count+=1
    if count==K:
        print(wari)
        exit()
    wari-=1 A,B,K= map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B K count=0 count 0 wari=min(A,B) wari min(A,B) min A B while True:
    if A%wari==0 and B%wari==0:
        count+=1
    if count==K:
        print(wari)
        exit()
    wari-=1 True if A%wari==0 and B%wari==0:
        count+=1
     A%wari==0 and B%wari==0 A%wari==0 A%wari A wari 0 B%wari==0 B%wari B wari 0 count+=1 count 1 if count==K:
        print(wari)
        exit()
     count==K count K print(wari) print wari exit() exit wari-=1 wari 1 K= map(int,input().split()) map(int,input().split()) K A,B,K= map(int,input().split()) map(int,input().split()) A count+=1 1 count wari-=1 1 wari count=0 0 count wari=min(A,B) min(A,B) wari B,K= map(int,input().split()) map(int,input().split()) B
# import math
# import statistics
# import itertools
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
A,B,K= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input().split for _ in range(a)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
count=0
wari=min(A,B)
while True:
    if A%wari==0 and B%wari==0:
        count+=1
    if count==K:
        print(wari)
        exit()
    wari-=1