import sys
a,b,k = map(int,input().split())
c = 0
if a > b:    
    for i in range(b,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()
else:
    for i in range(a,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit() import sys sys 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 if a > b:    
    for i in range(b,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()
else:
    for i in range(a,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit() a > b a b for i in range(b,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit() i range(b,0,-1) range b 0 -1 if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit() (b%i == 0) and (a%i == 0) b%i == 0 b%i b i 0 a%i == 0 a%i a i 0 c += 1 c 1 if c == k:
                print(i)
                sys.exit() c == k c k print(i) print i sys.exit() sys.exit sys exit for i in range(a,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit() i range(a,0,-1) range a 0 -1 if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit() (b%i == 0) and (a%i == 0) b%i == 0 b%i b i 0 a%i == 0 a%i a i 0 c += 1 c 1 if c == k:
                print(i)
                sys.exit() c == k c k print(i) print i sys.exit() sys.exit sys exit a,b,k = map(int,input().split()) map(int,input().split()) a b,k = map(int,input().split()) map(int,input().split()) b c += 1 1 c k = map(int,input().split()) map(int,input().split()) k c = 0 0 c c += 1 1 c
import sys
a,b,k = map(int,input().split())
c = 0
if a > b:    
    for i in range(b,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()
else:
    for i in range(a,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()