import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} Main public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    } main {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int result = 0; result 0 int count = 0; count 0 int max = Math.min(a, b); max Math.min(a, b) Math.min Math a b for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        } int i = max; int i = max; i max 0 < i 0 i i-- i-- i {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        } {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        } if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = 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) {
                    result = i;
                }
            } count++ count if (count == k) {
                    result = i;
                } count == k count k {
                    result = i;
                } result = i result i System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int result = 0;
        int count = 0;
        int max = Math.min(a, b);
        for (int i = max; 0 < i; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
                if (count == k) {
                    result = i;
                }
            }
        }

        // 出力
        System.out.println(result);
    }
}
