def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))
  

def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b)


def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k])

main() def mapt(fn, *args):
    return tuple(map(fn, *args)) mapt return tuple(map(fn, *args)) tuple(map(fn, *args)) tuple map(fn, *args) map fn *args args fn fn *args def Input():
    return mapt(int, input().split(" "))
   Input return mapt(int, input().split(" ")) mapt(int, input().split(" ")) mapt int input().split(" ") ().split () input split " " def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b) gcd """最大公約数""" if b == 0: return a
     b == 0 b 0 return gcd(b, a % b) gcd(b, a % b) gcd b a % b a b a a b b def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k]) main a, b, k = Input() a Input() Input b k k -= 1 k 1 i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0 for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0 i range(1, gcd(a, b)+1) range 1 gcd(a, b)+1 gcd(a, b) gcd a b 1 a % i == 0 and b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 if a % i == 0 and b % i == 0 i data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True) data sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True) sorted (i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0) reverse=True reverse True print(data[k]) print data[k] data k main() main def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k]) def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k]) main def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b) def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b) gcd def mapt(fn, *args):
    return tuple(map(fn, *args)) def mapt(fn, *args):
    return tuple(map(fn, *args)) mapt def Input():
    return mapt(int, input().split(" "))
   def Input():
    return mapt(int, input().split(" "))
   Input
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))
  

def gcd(a, b):
    """最大公約数"""
    if b == 0: return a
    return gcd(b, a % b)


def main():
    a, b, k = Input()
    k -= 1
    data = sorted((i for i in range(1, gcd(a, b)+1)
                   if a % i == 0 and b % i == 0), reverse=True)

    print(data[k])

main()