import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():

    A,B,K =map(int,input().split())

    count = 0
    for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit()



if __name__ == "__main__":
    main() import sys sys import math math def input():
    return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():

    A,B,K =map(int,input().split())

    count = 0
    for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit() main A,B,K =map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B K count = 0 count 0 for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit() i range(101,0,-1) range 101 0 -1 if A%i ==0 and B% i ==0:
            count +=1

         A%i ==0 and B% i ==0 A%i ==0 A%i A i 0 B% i ==0 B% i B i 0 count +=1 count 1 if count ==K:
            print(i)
            exit() count ==K count K print(i) print i exit() exit if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input def main():

    A,B,K =map(int,input().split())

    count = 0
    for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit() def main():

    A,B,K =map(int,input().split())

    count = 0
    for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit() main
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():

    A,B,K =map(int,input().split())

    count = 0
    for i in range(101,0,-1):
        if A%i ==0 and B% i ==0:
            count +=1

        if count ==K:
            print(i)
            exit()



if __name__ == "__main__":
    main()
