import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	}
} 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(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		} 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) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		} {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		} if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			} a%i==0&&b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			} if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				} k==1 k 1 {
					System.out.println(i);
					break;
				} System.out.println(i) System.out.println System.out System System.out i break; {
					k--;
				} k-- k sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; i--) {
			if(a%i==0&&b%i==0) {
				if(k==1) {
					System.out.println(i);
					break;
				}else {
					k--;
				}
			}
		}
		sc.close();
	}
}