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


if __name__ == "__main__":
    solve() def solve():
    A, B, K = list(map(int, input().split()))
    common_div = []
    for i in range(1, min(A, B)+1):
        if(A % i == 0 and B % i == 0):
            common_div.append(i)
    common_div.sort(reverse=True)
    print(common_div[K-1]) solve A, B, K = list(map(int, input().split())) A list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split B K common_div = [] common_div [] for i in range(1, min(A, B)+1):
        if(A % i == 0 and B % i == 0):
            common_div.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):
            common_div.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 common_div.append(i) common_div.append common_div append i common_div.sort(reverse=True) common_div.sort common_div sort reverse=True reverse True print(common_div[K-1]) print common_div[K-1] common_div K-1 K 1 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    A, B, K = list(map(int, input().split()))
    common_div = []
    for i in range(1, min(A, B)+1):
        if(A % i == 0 and B % i == 0):
            common_div.append(i)
    common_div.sort(reverse=True)
    print(common_div[K-1]) def solve():
    A, B, K = list(map(int, input().split()))
    common_div = []
    for i in range(1, min(A, B)+1):
        if(A % i == 0 and B % i == 0):
            common_div.append(i)
    common_div.sort(reverse=True)
    print(common_div[K-1]) solve
def solve():
    A, B, K = list(map(int, input().split()))
    common_div = []
    for i in range(1, min(A, B)+1):
        if(A % i == 0 and B % i == 0):
            common_div.append(i)
    common_div.sort(reverse=True)
    print(common_div[K-1])


if __name__ == "__main__":
    solve()