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 k = sc.nextInt();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    }
} 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 k = sc.nextInt();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    }
} 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();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.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 List<Integer> divsA = new ArrayList<>(); divsA new ArrayList<>() List<Integer> divsB = new ArrayList<>(); divsB new ArrayList<>() for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        } int i = 1; int i = 1; i 1 i <= a i a ++i ++i i {
            if (a % i == 0) divsA.add(i);
        } {
            if (a % i == 0) divsA.add(i);
        } if (a % i == 0) divsA.add(i); a % i == 0 a % i a i 0 divsA.add(i) divsA.add divsA i for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        } int i = 1; int i = 1; i 1 i <= b i b ++i ++i i {
            if (b % i == 0) divsB.add(i);
        } {
            if (b % i == 0) divsB.add(i);
        } if (b % i == 0) divsB.add(i); b % i == 0 b % i b i 0 divsB.add(i) divsB.add divsB i List<Integer> divs = new ArrayList<>(); divs new ArrayList<>() for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        } int i = 0; int i = 0; i 0 i < divsA.size() i divsA.size() divsA.size divsA ++i ++i i {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        } {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        } for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            } int j = 0; int j = 0; j 0 j < divsB.size() j divsB.size() divsB.size divsB ++j ++j j {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            } {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            } if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                } divsA.get(i) == divsB.get(j) divsA.get(i) divsA.get divsA i divsB.get(j) divsB.get divsB j {
                    divs.add(divsA.get(i));
                } divs.add(divsA.get(i)) divs.add divs divsA.get(i) divsA.get divsA i System.out.println(divs.get(divs.size() - k)) System.out.println System.out System System.out divs.get(divs.size() - k) divs.get divs divs.size() - k divs.size() divs.size divs k 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();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    }
} 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();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    }
} 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 k = sc.nextInt();

        List<Integer> divsA = new ArrayList<>();
        List<Integer> divsB = new ArrayList<>();
        for (int i = 1; i <= a; ++i) {
            if (a % i == 0) divsA.add(i);
        }
        for (int i = 1; i <= b; ++i) {
            if (b % i == 0) divsB.add(i);
        }

        List<Integer> divs = new ArrayList<>();
        for (int i = 0; i < divsA.size(); ++i) {
            for (int j = 0; j < divsB.size(); ++j) {
                if (divsA.get(i) == divsB.get(j)) {
                    divs.add(divsA.get(i));
                }
            }
        }

        System.out.println(divs.get(divs.size() - k));
    }
}