a,b,k = map(int,input().split())
c = 0
i = max(a,b)

while i > 0:
    if a % i == 0:
        if b % i == 0:
            c += 1

    if c == k:
        print(i)
        break

    i -= 1 a,b,k = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k c = 0 c 0 i = max(a,b) i max(a,b) max a b while i > 0:
    if a % i == 0:
        if b % i == 0:
            c += 1

    if c == k:
        print(i)
        break

    i -= 1 i > 0 i 0 if a % i == 0:
        if b % i == 0:
            c += 1

     a % i == 0 a % i a i 0 if b % i == 0:
            c += 1

     b % i == 0 b % i b i 0 c += 1 c 1 if c == k:
        print(i)
        break

     c == k c k print(i) print i break i -= 1 i 1 i -= 1 1 i c = 0 0 c a,b,k = map(int,input().split()) map(int,input().split()) a c += 1 1 c i = max(a,b) max(a,b) i k = map(int,input().split()) map(int,input().split()) k b,k = map(int,input().split()) map(int,input().split()) b
a,b,k = map(int,input().split())
c = 0
i = max(a,b)

while i > 0:
    if a % i == 0:
        if b % i == 0:
            c += 1

    if c == k:
        print(i)
        break

    i -= 1