import java.util.Scanner;

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 min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	}

} 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 min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	}

} 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 min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		int min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	} 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 min = Math.min(A, B); min Math.min(A, B) Math.min Math A B int count = 0; count 0 int val = 0; val 0 for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		} int i=min; int i=min; i min i>=1 i 1 i-- i-- i {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		} {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		} if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			} A%i==0 && B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			} count++ count val = i val i if(count==K) {
					break;
				} count==K count K {
					break;
				} break; System.out.println(val) System.out.println System.out System System.out val 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 min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	}

} 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 min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	}

} Main
import java.util.Scanner;

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 min = Math.min(A, B);
		int count = 0;
		int val = 0;
		for(int i=min; i>=1; i--) {
			if(A%i==0 && B%i==0) {
				count++;
				val = i;
				if(count==K) {
					break;
				}
			}
		}
		System.out.println(val);
	}

}