import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC120_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC120_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) ABC120_2 solver = new ABC120_2(); solver new ABC120_2() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC120_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        }

    } ABC120_2 public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        } solve {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        } int A = in.nextInt(); A in.nextInt() in.nextInt in int B = in.nextInt(); B in.nextInt() in.nextInt in int K = in.nextInt(); K in.nextInt() in.nextInt in int a = Math.max(A, B); a Math.max(A, B) Math.max Math A B int b = Math.min(A, B); b Math.min(A, B) Math.min Math A B int counter = b; counter b while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            } true {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            } if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                } (a % counter == 0) && (b % counter == 0) (a % counter == 0) a % counter a counter 0 (b % counter == 0) b % counter b counter 0 {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                } K-- K if (K == 0) {
                        out.println(counter);
                        return;
                    } K == 0 K 0 {
                        out.println(counter);
                        return;
                    } out.println(counter) out.println out counter return; counter-- counter int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC120_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC120_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC120_2 solver = new ABC120_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC120_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            int a = Math.max(A, B);
            int b = Math.min(A, B);
            int counter = b;
            while (true) {
                if ((a % counter == 0) && (b % counter == 0)) {
                    K--;
                    if (K == 0) {
                        out.println(counter);
                        return;
                    }
                }
                counter--;
            }
        }

    }
}

