import java.util.Scanner;

//AtCoder Beginner Contest 120
//B	K-th Common Divisor
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();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	}
} 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();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	}
} 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();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

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

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	} 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 sc.close() sc.close sc int ret = 0; ret 0 int x = 0; x 0 for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		} int i = 100; int i = 100; i 100 i >= 0 i 0 i-- i-- i {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		} {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		} if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			} A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			} ret = i ret i x++ x if (x == K) {
					break;
				} x == K x K {
					break;
				} break; System.out.print(ret) System.out.print System.out System System.out ret 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();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	}
} 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();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	}
} Main
import java.util.Scanner;

//AtCoder Beginner Contest 120
//B	K-th Common Divisor
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();

		sc.close();

		int ret = 0;
		int x = 0;
		for (int i = 100; i >= 0; i--) {
			if (A % i == 0 && B % i == 0) {
				ret = i;
				x++;
				if (x == K) {
					break;
				}
			}
		}

		System.out.print(ret);
	}
}
