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();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		sc.close();
	}
} 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();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		sc.close();
	}
} 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();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		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 int t = Math.min(A, B); t Math.min(A, B) Math.min Math A B int cnt = 0; cnt 0 while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		} cnt < K cnt K {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		} if (A % t == 0 && B % t == 0)
				cnt++; A % t == 0 && B % t == 0 A % t == 0 A % t A t 0 B % t == 0 B % t B t 0 cnt++ cnt t-- t System.out.println(t + 1) System.out.println System.out System System.out t + 1 t 1 sc.close() sc.close sc String[] args args 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();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		sc.close();
	}
} 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();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		sc.close();
	}
} 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();

		int t = Math.min(A, B);
		int cnt = 0;
		while (cnt < K) {
			if (A % t == 0 && B % t == 0)
				cnt++;
			t--;
		}

		System.out.println(t + 1);

		sc.close();
	}
}