def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break
resolve() def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break resolve import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline a, b, k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k x for x in range(1, min(a,b)+1) for x in range(1, min(a,b)+1) x range(1, min(a,b)+1) range 1 min(a,b)+1 min(a,b) min a b 1 for x in range(1, min(a,b)+1) x List = [x for x in range(1, min(a,b)+1)] List [x for x in range(1, min(a,b)+1)] List.sort(reverse=True) List.sort List sort reverse=True reverse True cnt = 0 cnt 0 for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break y List if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break a % y == 0 and b % y == 0 a % y == 0 a % y a y 0 b % y == 0 b % y b y 0 cnt += 1 cnt 1 if cnt == k:
                print(y)
                break cnt == k cnt k print(y) print y break resolve() resolve def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break resolve
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break
resolve()