a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
if a>=b:
  for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break
if a<b:
  for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break a,b,c=input().split() a input().split() ().split () input split b c a=int(a) a int(a) int a b=int(b) b int(b) int b c=int(c) c int(c) int c d=0 d 0 if a>=b:
  for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break a>=b a b for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break i range(101) range 101 if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break a%(b-i)==0 and b%(b-i)==0 a%(b-i)==0 a%(b-i) a b-i b i 0 b%(b-i)==0 b%(b-i) b b-i b i 0 d=d+1 d d+1 d 1 if d==c:
        print(b-i)
        break d==c d c print(b-i) print b-i b i break if a<b:
  for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break a<b a b for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break i range(101) range 101 if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break a%(a-i)==0 and b%(a-i)==0 a%(a-i)==0 a%(a-i) a a-i a i 0 b%(a-i)==0 b%(a-i) b a-i a i 0 d=d+1 d d+1 d 1 if d==c:
        print(a-i)
        break d==c d c print(a-i) print a-i a i break b,c=input().split() input().split() b d=d+1 d+1 d c=input().split() input().split() c d=d+1 d+1 d a=int(a) int(a) a c=int(c) int(c) c b=int(b) int(b) b d=0 0 d a,b,c=input().split() input().split() a
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
d=0
if a>=b:
  for i in range(101):
    if a%(b-i)==0 and b%(b-i)==0:
      d=d+1
      if d==c:
        print(b-i)
        break
if a<b:
  for i in range(101):
    if a%(a-i)==0 and b%(a-i)==0:
      d=d+1
      if d==c:
        print(a-i)
        break