import java.util.Scanner;

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

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

        System.out.println(solve(A, B, K));

        sc.close();
    }

    static int solve(int A, int B, int K) {
        int count = 0;
        for (int i = Math.min(A, B);; --i) {
            if (A % i == 0 && B % i == 0) {
                ++count;
                if (count == K) {
                    return i;
                }
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        System.out.println(solve(A, B, K));

        sc.close();
    }

    static int solve(int A, int B, int K) {
        int count = 0;
        for (int i = Math.min(A, B);; --i) {
            if (A % i == 0 && B % i == 0) {
                ++count;
                if (count == K) {
                    return i;
                }
            }
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        System.out.println(solve(A, B, K));

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

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

        System.out.println(solve(A, B, K));

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

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

        System.out.println(solve(A, B, K));

        sc.close();
    }

    static int solve(int A, int B, int K) {
        int count = 0;
        for (int i = Math.min(A, B);; --i) {
            if (A % i == 0 && B % i == 0) {
                ++count;
                if (count == K) {
                    return i;
                }
            }
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

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

        System.out.println(solve(A, B, K));

        sc.close();
    }

    static int solve(int A, int B, int K) {
        int count = 0;
        for (int i = Math.min(A, B);; --i) {
            if (A % i == 0 && B % i == 0) {
                ++count;
                if (count == K) {
                    return i;
                }
            }
        }
    }
} Main
import java.util.Scanner;

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

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

        System.out.println(solve(A, B, K));

        sc.close();
    }

    static int solve(int A, int B, int K) {
        int count = 0;
        for (int i = Math.min(A, B);; --i) {
            if (A % i == 0 && B % i == 0) {
                ++count;
                if (count == K) {
                    return i;
                }
            }
        }
    }
}