import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        }

    }
}
 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.List; List java.util import java.util.Scanner; Scanner java.util import java.util.Collections; Collections java.util import java.util.ArrayList; ArrayList 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        }

    }
} 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);
        B solver = new B();
        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);
        B solver = new B();
        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) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        }

    } B public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        } solve {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        } int a = Integer.parseInt(in.next()); a Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int b = Integer.parseInt(in.next()); b Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in int k = Integer.parseInt(in.next()); k Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in List<Integer> ans = new ArrayList<>(); ans new ArrayList<>() int i = 1; i 1 while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            } true {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            } if (i > a && i > b) break; i > a && i > b i > a i a i > b i b break; if (a % i == 0 && b % i == 0) ans.add(i); a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 ans.add(i) ans.add ans i i++ i Collections.sort(ans, Collections.reverseOrder()) Collections.sort Collections ans Collections.reverseOrder() Collections.reverseOrder Collections out.println(ans.get(k - 1)) out.println out ans.get(k - 1) ans.get ans k - 1 k 1 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        }

    }
} 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        }

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

/**
 * 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            List<Integer> ans = new ArrayList<>();

            int i = 1;
            while (true) {
                if (i > a && i > b) break;

                if (a % i == 0 && b % i == 0) ans.add(i);

                i++;
            }

            Collections.sort(ans, Collections.reverseOrder());
            // 出力
            out.println(ans.get(k - 1));

        }

    }
}

