import math

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

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