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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 1));
    }

}


 import java.util.ArrayList; ArrayList 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 = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 1));
    }

} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 1));
    } main {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 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 K = sc.nextInt(); K sc.nextInt() sc.nextInt sc ArrayList<Integer> commonDivisors = new ArrayList<>(); commonDivisors new ArrayList<>() int idx = Math.min(A, B); idx Math.min(A, B) Math.min Math A B for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        } int i = idx; int i = idx; i idx i > 0 i 0 i-- i-- i {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        } {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        } if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            } commonDivisors.add(i) commonDivisors.add commonDivisors i if (commonDivisors.size() == K) {
                    break;
                } commonDivisors.size() == K commonDivisors.size() commonDivisors.size commonDivisors K {
                    break;
                } break; System.out.println(commonDivisors.get(K - 1)) System.out.println System.out System System.out commonDivisors.get(K - 1) commonDivisors.get commonDivisors K - 1 K 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 K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 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 K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 1));
    }

} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        ArrayList<Integer> commonDivisors = new ArrayList<>();
        int idx = Math.min(A, B);

        for (int i = idx; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                commonDivisors.add(i);
                if (commonDivisors.size() == K) {
                    break;
                }
            }
        }

        System.out.println(commonDivisors.get(K - 1));
    }

}



