import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    a,b,k = map(int, input().split())
    n = min(a,b)
    num = []
    for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

    num.sort(reverse=True)
    
    print(num[k-1])

if __name__ == "__main__":
    main() import os os import sys sys from collections import defaultdict, Counter from itertools import product, permutations,combinations, accumulate from operator import itemgetter from bisect import bisect_left,bisect from heapq import heappop,heappush from math import ceil, floor, sqrt, gcd from copy import deepcopy def main():
    a,b,k = map(int, input().split())
    n = min(a,b)
    num = []
    for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

    num.sort(reverse=True)
    
    print(num[k-1]) main a,b,k = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b k n = min(a,b) n min(a,b) min a b num = [] num [] for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

     i range(1,n+1,1) range 1 n+1 n 1 1 if (a%i == 0) and (b%i == 0):
            num.append(i)

     (a%i == 0) and (b%i == 0) a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 num.append(i) num.append num append i num.sort(reverse=True) num.sort num sort reverse=True reverse True print(num[k-1]) print num[k-1] num k-1 k 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    a,b,k = map(int, input().split())
    n = min(a,b)
    num = []
    for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

    num.sort(reverse=True)
    
    print(num[k-1]) def main():
    a,b,k = map(int, input().split())
    n = min(a,b)
    num = []
    for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

    num.sort(reverse=True)
    
    print(num[k-1]) main
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    a,b,k = map(int, input().split())
    n = min(a,b)
    num = []
    for i in range(1,n+1,1):
        if (a%i == 0) and (b%i == 0):
            num.append(i)

    num.sort(reverse=True)
    
    print(num[k-1])

if __name__ == "__main__":
    main()