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 main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k])

if __name__ == '__main__':
    main() 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 def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k]) main a,b,k = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k from math import gcd y = make_divisors(gcd(a,b)) y make_divisors(gcd(a,b)) make_divisors gcd(a,b) gcd a b print(y[-k]) print y[-k] y -k k if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k]) def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k]) main 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]

def main():
    a,b,k = map(int,input().split())
    from math import gcd
    y = make_divisors(gcd(a,b))
    print(y[-k])

if __name__ == '__main__':
    main()
