import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    } 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 num = Integer.parseInt(sc.next()); num Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] canDivided = new int[Math.max(a, b)]; canDivided new int[Math.max(a, b)] Math.max(a, b) Math.max Math a b for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        } int i = 0; int i = 0; i 0 i < canDivided.length i canDivided.length canDivided canDivided.length i++ i++ i {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        } {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        } if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            } a % (i + 1) == 0 && b % (i + 1) == 0 a % (i + 1) == 0 a % (i + 1) a (i + 1) i 1 0 b % (i + 1) == 0 b % (i + 1) b (i + 1) i 1 0 {
                canDivided[i] = i + 1;
            } canDivided[i] = i + 1 canDivided[i] canDivided i i + 1 i 1 Arrays.sort(canDivided) Arrays.sort Arrays canDivided System.out.println(canDivided[canDivided.length - num]) System.out.println System.out System System.out canDivided[canDivided.length - num] canDivided canDivided.length - num canDivided.length canDivided canDivided.length num String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int num = Integer.parseInt(sc.next());
        int[] canDivided = new int[Math.max(a, b)];
        for (int i = 0; i < canDivided.length; i++) {
            if (a % (i + 1) == 0 && b % (i + 1) == 0) {
                canDivided[i] = i + 1;
            }
        }
        Arrays.sort(canDivided);
        System.out.println(canDivided[canDivided.length - num]);
    }
}
