import sys
from io import StringIO
import unittest
import math

def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
            
resolve() import sys sys from io import StringIO import unittest unittest import math math def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
             resolve inp = input() inp input() input li = list(map(lambda x: int(x), inp.split(" "))) li list(map(lambda x: int(x), inp.split(" "))) list map(lambda x: int(x), inp.split(" ")) map lambda x: int(x) int(x) int x x inp.split(" ") inp.split inp split " " a = li[0] a li[0] li 0 b = li[1] b li[1] li 1 k = li[2] k li[2] li 2 g = math.gcd(a, b) g math.gcd(a, b) math.gcd math gcd a b for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
             i range(g,0,-1) range g 0 -1 if g%i == 0:
            k -= 1
         g%i == 0 g%i g i 0 k -= 1 k 1 if k == 0:
            print(i)
            break
             k == 0 k 0 print(i) print i break resolve() resolve def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
             def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
             resolve
import sys
from io import StringIO
import unittest
import math

def resolve():
    inp = input()
    li = list(map(lambda x: int(x), inp.split(" ")))
    a = li[0]
    b = li[1]
    k = li[2]
    g = math.gcd(a, b)

    for i in range(g,0,-1):
        if g%i == 0:
            k -= 1
        if k == 0:
            print(i)
            break
            
resolve()