#
# abc120 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    A, B, K = map(int, input().split())

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


if __name__ == "__main__":
     # unittest.main()
     resolve() import sys sys from io import StringIO import unittest unittest class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output) TestClass def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

     assertIO stdout, stdin = sys.stdout, sys.stdin stdout sys.stdout sys stdout stdin sys.stdin sys stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) sys.stdout sys stdout StringIO() StringIO sys.stdin sys stdin StringIO(input) StringIO input resolve() resolve sys.stdout.seek(0) sys.stdout.seek sys.stdout sys stdout seek 0 out = sys.stdout.read()[:-1] out sys.stdout.read()[:-1] sys.stdout.read() sys.stdout.read sys.stdout sys stdout read :-1 -1 sys.stdout, sys.stdin = stdout, stdin sys.stdout sys stdout stdout sys.stdin sys stdin stdin self.assertEqual(out, output) self.assertEqual self assertEqual out output self self input input output output def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

     test_入力例_1 input = """8 12 2""" input """8 12 2""" output = """2""" output """2""" self.assertIO(input, output) self.assertIO self assertIO input output self self def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

     test_入力例_2 input = """100 50 4""" input """100 50 4""" output = """5""" output """5""" self.assertIO(input, output) self.assertIO self assertIO input output self self def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output) test_入力例_3 input = """1 1 1""" input """1 1 1""" output = """1""" output """1""" self.assertIO(input, output) self.assertIO self assertIO input output self self unittest.TestCase unittest TestCase def resolve():
    A, B, K = map(int, input().split())

    n = 0
    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            n += 1
            if n == K:
                print(i)
                exit resolve A, B, K = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B K n = 0 n 0 for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            n += 1
            if n == 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:
            n += 1
            if n == 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 n += 1 n 1 if n == K:
                print(i)
                exit n == K n K print(i) print i exit if __name__ == "__main__":
     # unittest.main()
     resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    A, B, K = map(int, input().split())

    n = 0
    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            n += 1
            if n == K:
                print(i)
                exit def resolve():
    A, B, K = map(int, input().split())

    n = 0
    for i in range(min(A, B), 0, -1):
        if A % i == 0 and B % i == 0:
            n += 1
            if n == K:
                print(i)
                exit resolve class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output) class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output) TestClass
#
# abc120 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 12 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100 50 4"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 1 1"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    A, B, K = map(int, input().split())

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


if __name__ == "__main__":
     # unittest.main()
     resolve()
