import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	} main {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		} 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(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		} {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		} if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} K-- K if(K == 0) {
					System.out.println(i);
				} K == 0 K 0 {
					System.out.println(i);
				} System.out.println(i) System.out.println System.out System System.out i String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		for(int i = Math.min(A, B); i >= 1; i--) {
			if(A % i == 0 && B % i == 0) {
				K--;
				if(K == 0) {
					System.out.println(i);
				}
			} 
		}
	}
}