import java.util.*;

public class Main {
    //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    }

    public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    }
} import java.util.*; util.* java public class Main {
    //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    }

    public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    }
} Main //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(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 b = sc.nextInt() b sc.nextInt() sc.nextInt sc k = sc.nextInt(); k sc.nextInt() sc.nextInt sc System.out.println(helper(a, b, k)) System.out.println System.out System System.out helper(a, b, k) helper a b k sc.close() sc.close sc String[] args args public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    } helper {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    } int count = 0; count 0 for (int i = Math.min(a, b); i >= 1; 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 >= 1 i 1 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++; a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 count++ count if (count == k) return i; count == k count k return i; i return 0; 0 int a a int b b int k k public class Main {
    //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    }

    public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    }
} public class Main {
    //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    }

    public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    }
} Main
import java.util.*;

public class Main {
    //K-th Common Divisor
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), k = sc.nextInt();
        System.out.println(helper(a, b, k));
        sc.close();
    }

    public static int helper(int a, int b, int k) {
        int count = 0;
        for (int i = Math.min(a, b); i >= 1; i--) {
            if (a % i == 0 && b % i == 0) count++;
            if (count == k) return i;
        }
        return 0;
    }
}
