def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
  
A,B,K = (int(X) for X in input().split())
Count = 0
Divid = Div(min(A,B))
for T in Divid:
    if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
   Div L = [] L [] R = [] R [] I = 1 I 1 while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
     I*I<=N I*I I I N if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
         N%I==0 N%I N I 0 L.append(I) L.append L append I if I!=N//I: R.append(N//I)
         I!=N//I I N//I N I I += 1 I 1 return R+L[::-1] R+L[::-1] R L[::-1] L ::-1 -1 N N int(X) for X in input().split() for X in input().split() X input().split() ().split () input split for X in input().split() int(X) int X A,B,K = (int(X) for X in input().split()) A (int(X) for X in input().split()) B K Count = 0 Count 0 Divid = Div(min(A,B)) Divid Div(min(A,B)) Div min(A,B) min A B for T in Divid:
    if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break T Divid if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break A%T==0 and B%T==0 A%T==0 A%T A T 0 B%T==0 B%T B T 0 Count += 1 Count 1 if Count==K:
            print(T)
            break Count==K Count K print(T) print T break Count = 0 0 Count A,B,K = (int(X) for X in input().split()) (int(X) for X in input().split()) A K = (int(X) for X in input().split()) (int(X) for X in input().split()) K Divid = Div(min(A,B)) Div(min(A,B)) Divid B,K = (int(X) for X in input().split()) (int(X) for X in input().split()) B def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
   def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
   Div Count += 1 1 Count
def Div(N):
    L = []
    R = []
    I = 1
    while I*I<=N:
        if N%I==0:
            L.append(I)
            if I!=N//I: R.append(N//I)
        I += 1
    return R+L[::-1]
  
A,B,K = (int(X) for X in input().split())
Count = 0
Divid = Div(min(A,B))
for T in Divid:
    if A%T==0 and B%T==0:
        Count += 1
        if Count==K:
            print(T)
            break