#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b,k=map(int,input().split())
g=math.gcd(a,b)
d=[]
for i in range(1,int(pow(g,0.5))+1):
  if g%i==0:
    d.append(i)
    if g//i not in d:
      d.append(g//i)
d.sort(reverse=True)
print(d[k-1]) import math math from collections import deque from collections import Counter a,b,k=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k g=math.gcd(a,b) g math.gcd(a,b) math.gcd math gcd a b d=[] d [] for i in range(1,int(pow(g,0.5))+1):
  if g%i==0:
    d.append(i)
    if g//i not in d:
      d.append(g//i) i range(1,int(pow(g,0.5))+1) range 1 int(pow(g,0.5))+1 int(pow(g,0.5)) int pow(g,0.5) pow g 0.5 1 if g%i==0:
    d.append(i)
    if g//i not in d:
      d.append(g//i) g%i==0 g%i g i 0 d.append(i) d.append d append i if g//i not in d:
      d.append(g//i) g//i not in d g//i g i d d.append(g//i) d.append d append g//i g i d.sort(reverse=True) d.sort d sort reverse=True reverse True print(d[k-1]) print d[k-1] d k-1 k 1 g=math.gcd(a,b) math.gcd(a,b) g b,k=map(int,input().split()) map(int,input().split()) b k=map(int,input().split()) map(int,input().split()) k a,b,k=map(int,input().split()) map(int,input().split()) a d=[] [] d
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b,k=map(int,input().split())
g=math.gcd(a,b)
d=[]
for i in range(1,int(pow(g,0.5))+1):
  if g%i==0:
    d.append(i)
    if g//i not in d:
      d.append(g//i)
d.sort(reverse=True)
print(d[k-1])