#!/usr/bin/env python3

def solve(a,b,k):
    l = []
    for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
    return(l[-k])

def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K))


if __name__ == '__main__':
    main() def solve(a,b,k):
    l = []
    for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
    return(l[-k]) solve l = [] l [] for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
     i range(min(a,b)) range min(a,b) min a b if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
     a % (i+1) == 0 and b % (i+1) == 0 a % (i+1) == 0 a % (i+1) a i+1 i 1 0 b % (i+1) == 0 b % (i+1) b i+1 i 1 0 l.append(i+1) l.append l append i+1 i 1 return(l[-k]) l[-k] l -k k a a b b k k def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K)) main A,B,K =map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B K print(solve(A,B,K)) print solve(A,B,K) solve A B K if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def solve(a,b,k):
    l = []
    for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
    return(l[-k]) def solve(a,b,k):
    l = []
    for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
    return(l[-k]) solve def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K)) def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K)) main
#!/usr/bin/env python3

def solve(a,b,k):
    l = []
    for i in range(min(a,b)):
        if a % (i+1) == 0 and b % (i+1) == 0:
            l.append(i+1)
    return(l[-k])

def main():
    A,B,K =map(int,input().split())
    print(solve(A,B,K))


if __name__ == '__main__':
    main()