import 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();

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	}
} import java.util.*; util.* java 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();

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	}
} 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();

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

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

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	} 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 int min = Math.min(A, B); min Math.min(A, B) Math.min Math A B int n = 0; n 0 for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		} int i=min; int i=min; i min i>0 i 0 i-- i-- i {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		} {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		} if(A % i == 0 && B % i == 0) {
				n++;
			} A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
				n++;
			} n++ n if(n==K) {
				System.out.println(i);
				break;
			} n==K n 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) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	}
} 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();

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	}
} Main
import 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();

		int min = Math.min(A, B);
		int n = 0;

		for(int i=min; i>0; i--) {
			if(A % i == 0 && B % i == 0) {
				n++;
			}

			if(n==K) {
				System.out.println(i);
				break;
			}
		}

	}
}
