import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc sc.close() sc.close sc Integer[] divisors = new Integer[Math.max(a, b)]; divisors new Integer[Math.max(a, b)] Math.max(a, b) Math.max Math a b Arrays.fill(divisors, 0) Arrays.fill Arrays divisors 0 for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        } int i = 1; int i = 1; i 1 i <= Math.max(a, b) i Math.max(a, b) Math.max Math a b i++ i++ i {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        } {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        } if (a % i == 0 && b % i == 0) divisors[i - 1] = i; a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 divisors[i - 1] = i divisors[i - 1] divisors i - 1 i 1 i Arrays.sort(divisors, Comparator.reverseOrder()) Arrays.sort Arrays divisors Comparator.reverseOrder() Comparator.reverseOrder Comparator System.out.println(divisors[c - 1]) System.out.println System.out System System.out divisors[c - 1] divisors c - 1 c 1 String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();;
        int b = sc.nextInt();;
        int c = sc.nextInt();
        sc.close();
        Integer[] divisors = new Integer[Math.max(a, b)];
        Arrays.fill(divisors, 0);
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) divisors[i - 1] = i;
        }
        Arrays.sort(divisors, Comparator.reverseOrder());
        System.out.println(divisors[c - 1]);
    }
}