import java.util.Scanner;

public class Main {

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    }
} Main public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    } process {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    } final int A = testCase.A; A testCase.A testCase testCase.A final int B = testCase.B; B testCase.B testCase testCase.B int K = testCase.K; K testCase.K testCase testCase.K final int range = Math.min(A, B); range Math.min(A, B) Math.min Math A B for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        } int i = range; int i = range; i range i >= 1 i 1 --i --i i {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        } {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        } if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            } (A % i == 0) && (B % i == 0) (A % i == 0) A % i A i 0 (B % i == 0) B % i B i 0 {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            } K-- K if (K == 0) {
                    return String.valueOf(i);
                } K == 0 K 0 {
                    return String.valueOf(i);
                } return String.valueOf(i); String.valueOf(i) String.valueOf String i throw new IllegalArgumentException("no solution"); new IllegalArgumentException("no solution") TestCase testCase testCase public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    } main {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    } TestCase testCase = readFromInput(); testCase readFromInput() readFromInput final String result = process(testCase); result process(testCase) process testCase output(result) output result String[] args args private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    } readFromInput {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, 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 return new TestCase(A, B, K); new TestCase(A, B, K) private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    } unknownN {
        return new IllegalArgumentException("Unknown N: " + N);
    } return new IllegalArgumentException("Unknown N: " + N); new IllegalArgumentException("Unknown N: " + N) int N N private static void output(String result) {
        System.out.println(result);
    } output {
        System.out.println(result);
    } System.out.println(result) System.out.println System.out System System.out result String result result public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    } TestCase final int A; A final int B; B final int K; K public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        } TestCase {
            this.A = A;
            this.B = B;
            this.K = K;
        } this.A = A this.A this this.A A this.B = B this.B this this.B B this.K = K this.K this this.K K int A A int B B int K K public class Main {

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    }
} public class Main {

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    }
} Main
import java.util.Scanner;

public class Main {

    public static String process(TestCase testCase) {
        final int A = testCase.A;
        final int B = testCase.B;
        int K = testCase.K;

        final int range = Math.min(A, B);

        for (int i = range; i >= 1; --i) {
            if ((A % i == 0) && (B % i == 0)) {
                K--;
                if (K == 0) {
                    return String.valueOf(i);
                }
            }

        }

        throw new IllegalArgumentException("no solution");
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        return new TestCase(A, B, K);
    }

    private static IllegalArgumentException unknownN(int N) {
        return new IllegalArgumentException("Unknown N: " + N);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int A;
        final int B;
        final int K;

        public TestCase(int A, int B, int K) {
            this.A = A;
            this.B = B;
            this.K = K;
        }
    }
}
