import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	}

} Main public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	} main {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	} final Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) final int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner final int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner final int c = scanner.nextInt(); c scanner.nextInt() scanner.nextInt scanner int i = 0; i 0 int result = Math.max(a, b); result Math.max(a, b) Math.max Math a b while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		} true {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		} if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			} a % result == 0 && b % result == 0 a % result == 0 a % result a result 0 b % result == 0 b % result b result 0 {
				if (++i == c) {
					break;
				}
			} if (++i == c) {
					break;
				} ++i == c ++i i c {
					break;
				} break; result-- result 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) {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	}

} public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		final int a = scanner.nextInt();
		final int b = scanner.nextInt();
		final int c = scanner.nextInt();

		int i = 0;
		int result = Math.max(a, b);
		while (true) {
			if (a % result == 0 && b % result == 0) {
				if (++i == c) {
					break;
				}
			}
			result--;
		}
		System.out.println(result);
	}

}