import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A A B B K; K A = sc.nextInt() A sc.nextInt() sc.nextInt sc B = sc.nextInt() B sc.nextInt() sc.nextInt sc K = sc.nextInt() K sc.nextInt() sc.nextInt sc sc.close() sc.close sc int a = 0; a 0 int ans = 0; ans 0 for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		} int i = 100; int i = 100; i 100 i >= 1 i 1 i-- i-- i {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		} {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		} if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			} A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
				a++;
				if (a == K) {
					ans = i;
				}
			} a++ a if (a == K) {
					ans = i;
				} a == K a K {
					ans = i;
				} ans = i ans i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A, B, K;
		A = sc.nextInt();
		B = sc.nextInt();
		K = sc.nextInt();
		sc.close();
		int a = 0;
		int ans = 0;
		for (int i = 100; i >= 1; i--) {
			if (A % i == 0 && B % i == 0) {
				a++;
				if (a == K) {
					ans = i;
				}
			}
		}
		System.out.println(ans);
	}
}
