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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    } main {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    } 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 k = sc.nextInt(); k sc.nextInt() sc.nextInt sc sc.close() sc.close sc ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= 100 i 100 i++ i++ i {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } if (a % i == 0 && b % i == 0) {
                list.add(i);
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                list.add(i);
            } list.add(i) list.add list i System.out.println(list.get(list.size() - k)) System.out.println System.out System System.out list.get(list.size() - k) list.get list list.size() - k list.size() list.size list k String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        sc.close();

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= 100; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - k));
    }
}