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

public class Main {

    static PrintStream out = System.out;

    static void solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

    static PrintStream out = System.out;

    static void solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    }
} Main static PrintStream out = System.out; out System.out System System.out static void solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    } solve {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    } 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 res = 0; res 0 int cnt = 0; cnt 0 for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        } int i = Math.min(A, B); int i = Math.min(A, B); i Math.min(A, B) Math.min Math A B i >= 1 i 1 i-- i-- i {
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        } {
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        } if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            } A%i == 0 && B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 {
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            } cnt++ cnt if(cnt == k){
                    res = i;
                    break;
                } cnt == k cnt k {
                    res = i;
                    break;
                } res = i res i break; System.out.println(res) System.out.println System.out System System.out res Scanner in in public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    } main {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    } Scanner in = new Scanner(new BufferedInputStream(System.in)); in new Scanner(new BufferedInputStream(System.in)) solve(in) solve in String[] args args public class Main {

    static PrintStream out = System.out;

    static void solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    }
} public class Main {

    static PrintStream out = System.out;

    static void solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    }
} Main
import java.io.*;
import java.util.*;

public class Main {

    static PrintStream out = System.out;

    static void solve(Scanner in) {

        int A = in.nextInt();
        int B = in.nextInt();
        int k = in.nextInt();


        int res = 0;
        int cnt = 0;
        for(int i = Math.min(A, B); i >= 1; i--){
            if(A%i == 0 && B%i == 0){
                cnt++;
                if(cnt == k){
                    res = i;
                    break;
                }
            }
        }
        System.out.println(res);

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        solve(in);
    }
}