import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, k = rm()
t = math.gcd(a, b)
cnt = 0
for i in range(t, 0, -1):
  if t % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      exit()
  
    







 import sys sys import math math import itertools itertools import collections collections import heapq heapq import re re import numpy as np numpy rr = lambda: sys.stdin.readline().rstrip() rr lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip rs = lambda: sys.stdin.readline().split() rs lambda: sys.stdin.readline().split() sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split ri = lambda: int(sys.stdin.readline()) ri lambda: int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rm = lambda: map(int, sys.stdin.readline().split()) rm lambda: map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split rl = lambda: list(map(int, sys.stdin.readline().split())) rl lambda: list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split inf = float('inf') inf float('inf') float 'inf' mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 a, b, k = rm() a rm() rm b k t = math.gcd(a, b) t math.gcd(a, b) math.gcd math gcd a b cnt = 0 cnt 0 for i in range(t, 0, -1):
  if t % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      exit()
  
     i range(t, 0, -1) range t 0 -1 if t % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      exit()
  
     t % i == 0 t % i t i 0 cnt += 1 cnt 1 if cnt == k:
      print(i)
      exit()
  
     cnt == k cnt k print(i) print i exit() exit ri = lambda: int(sys.stdin.readline()) lambda: int(sys.stdin.readline()) ri mod = 10**9 + 7 10**9 + 7 mod b, k = rm() rm() b cnt += 1 1 cnt rl = lambda: list(map(int, sys.stdin.readline().split())) lambda: list(map(int, sys.stdin.readline().split())) rl rr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() rr cnt = 0 0 cnt a, b, k = rm() rm() a t = math.gcd(a, b) math.gcd(a, b) t rs = lambda: sys.stdin.readline().split() lambda: sys.stdin.readline().split() rs k = rm() rm() k inf = float('inf') float('inf') inf rm = lambda: map(int, sys.stdin.readline().split()) lambda: map(int, sys.stdin.readline().split()) rm
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b, k = rm()
t = math.gcd(a, b)
cnt = 0
for i in range(t, 0, -1):
  if t % i == 0:
    cnt += 1
    if cnt == k:
      print(i)
      exit()
  
    








