def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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


set_a = set(make_divisors(a))
set_b = set(make_divisors(b))

both = list(set_a & set_b)
both.sort()

print(both[- k]) def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors lower_divisors, upper_divisors = [], [] lower_divisors [] upper_divisors [] i = 1 i 1 while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
     i*i <= n i*i i i n if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
         n % i == 0 n % i n i 0 lower_divisors.append(i) lower_divisors.append lower_divisors append i if i != n // i:
                upper_divisors.append(n//i)
         i != n // i i n // i n i upper_divisors.append(n//i) upper_divisors.append upper_divisors append n//i n i i += 1 i 1 return lower_divisors + upper_divisors[::-1] lower_divisors + upper_divisors[::-1] lower_divisors upper_divisors[::-1] upper_divisors ::-1 -1 n n a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k set_a = set(make_divisors(a)) set_a set(make_divisors(a)) set make_divisors(a) make_divisors a set_b = set(make_divisors(b)) set_b set(make_divisors(b)) set make_divisors(b) make_divisors b both = list(set_a & set_b) both list(set_a & set_b) list set_a & set_b set_a set_b both.sort() both.sort both sort print(both[- k]) print both[- k] both - k k both = list(set_a & set_b) list(set_a & set_b) both set_b = set(make_divisors(b)) set(make_divisors(b)) set_b a, b, k = map(int, input().split()) map(int, input().split()) a b, k = map(int, input().split()) map(int, input().split()) b set_a = set(make_divisors(a)) set(make_divisors(a)) set_a k = map(int, input().split()) map(int, input().split()) k def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1] make_divisors
def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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


set_a = set(make_divisors(a))
set_b = set(make_divisors(b))

both = list(set_a & set_b)
both.sort()

print(both[- k])