import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        temp += 1
        if temp == K:
            print(i)
            exit() import sys sys from itertools import combinations import math math def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) LS A, B, K = LI() A LI() LI B K temp = 0 temp 0 for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        temp += 1
        if temp == K:
            print(i)
            exit() i range(min(A, B), 0, -1) range min(A, B) min A B 0 -1 if A % i == 0 and B % i == 0:
        temp += 1
        if temp == K:
            print(i)
            exit() A % i == 0 and B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 temp += 1 temp 1 if temp == K:
            print(i)
            exit() temp == K temp K print(i) print i exit() exit def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S temp = 0 0 temp temp += 1 1 temp def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I A, B, K = LI() LI() A def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS B, K = LI() LI() B K = LI() LI() K def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) LI
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(min(A, B), 0, -1):
    if A % i == 0 and B % i == 0:
        temp += 1
        if temp == K:
            print(i)
            exit()
