import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    }
} Main public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    } main {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc ArrayList<Integer> commonDivisor = new ArrayList<>(); commonDivisor new ArrayList<>() for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(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) {
                commonDivisor.add(i);
            }
        } {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        } if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                commonDivisor.add(i);
            } commonDivisor.add(i) commonDivisor.add commonDivisor i Collections.sort(commonDivisor) Collections.sort Collections commonDivisor System.out.println(commonDivisor.get(commonDivisor.size() - k)) System.out.println System.out System System.out commonDivisor.get(commonDivisor.size() - k) commonDivisor.get commonDivisor commonDivisor.size() - k commonDivisor.size() commonDivisor.size commonDivisor k String args[] args public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    }
} public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    }
}