import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		} {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int a = scanner.nextInt() a scanner.nextInt() scanner.nextInt scanner b = scanner.nextInt() b scanner.nextInt() scanner.nextInt scanner k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			} 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 ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			} {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			} if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				} (0 == (a % i)) && (0 == (b % i)) (0 == (a % i)) 0 (a % i) a i (0 == (b % i)) 0 (b % i) b i {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				} if (0 == --k) {
						System.out.println(i);
						break;
					} 0 == --k 0 --k k {
						System.out.println(i);
						break;
					} System.out.println(i) System.out.println System.out System System.out i break; String[] args args public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
}
