def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[-k])
resolve()     def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[-k]) resolve a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k t = [] t [] for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.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:
            t.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 t.append(i) t.append t append i print(t[-k]) print t[-k] t -k k resolve() resolve def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[-k]) def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[-k]) resolve
def resolve():
    a, b, k = map(int, input().split())
    t = []
    for i in range(1, min(a,b)+1):
        if a % i == 0 and b % i == 0:
            t.append(i)
    print(t[-k])
resolve()    