import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, K = map(int, readline().split())

    vec = []
    for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

    print(vec[-K])
    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    A, B, K = map(int, readline().split())

    vec = []
    for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

    print(vec[-K])
    return main A, B, K = map(int, readline().split()) A map(int, readline().split()) map int readline().split() ().split () readline split B K vec = [] vec [] for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

     n range(1, max(A, B) + 1) range 1 max(A, B) + 1 max(A, B) max A B 1 if A % n == 0 and B % n == 0:
            vec.append(n)

     A % n == 0 and B % n == 0 A % n == 0 A % n A n 0 B % n == 0 B % n B n 0 vec.append(n) vec.append vec append n print(vec[-K]) print vec[-K] vec -K K return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main MOD = 1000000007 1000000007 MOD readline = sys.stdin.readline sys.stdin.readline readline read = sys.stdin.read sys.stdin.read read def main():
    A, B, K = map(int, readline().split())

    vec = []
    for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

    print(vec[-K])
    return def main():
    A, B, K = map(int, readline().split())

    vec = []
    for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

    print(vec[-K])
    return main INF = 1 << 60 1 << 60 INF readlines = sys.stdin.readlines sys.stdin.readlines readlines
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B, K = map(int, readline().split())

    vec = []
    for n in range(1, max(A, B) + 1):
        if A % n == 0 and B % n == 0:
            vec.append(n)

    print(vec[-K])
    return


if __name__ == '__main__':
    main()
