import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} Main public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    } main {
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    } FastScanner fs = new FastScanner(); fs new FastScanner() PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) int a = fs.nextInt(); a fs.nextInt() fs.nextInt fs int b = fs.nextInt(); b fs.nextInt() fs.nextInt fs int k = fs.nextInt(); k fs.nextInt() fs.nextInt fs int l = Math.min(a, b); l Math.min(a, b) Math.min Math a b int kk = 0; kk 0 while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        } true {
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        } if(a % l == 0 && b % l == 0){
                kk++;
            } a % l == 0 && b % l == 0 a % l == 0 a % l a l 0 b % l == 0 b % l b l 0 {
                kk++;
            } kk++ kk if(kk >= k){
                break;
            } kk >= k kk k {
                break;
            } break; l-- l pw.println(l) pw.println pw l pw.flush() pw.flush pw String[] args args static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    } gcd {
        return b > 0 ? gcd(b, a % b) : a;
    } return b > 0 ? gcd(b, a % b) : a; b > 0 ? gcd(b, a % b) : a b > 0 b 0 gcd(b, a % b) gcd b a % b a b a int a a int b b public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    } FastScanner BufferedReader br; br StringTokenizer st; st public FastScanner(Reader in) {
            br = new BufferedReader(in);
        } FastScanner {
            br = new BufferedReader(in);
        } br = new BufferedReader(in) br new BufferedReader(in) Reader in in public FastScanner() {
            this(new InputStreamReader(System.in));
        } FastScanner {
            this(new InputStreamReader(System.in));
        } this(new InputStreamReader(System.in)) this new InputStreamReader(System.in) String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            } try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } IOException e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt() {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong() {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble() {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } readNextLine {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
