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(), k = sc.nextInt();
		int [] Array = new int [50];
		int counter = 0;
		for(int i = 1; i <= a && i <= b; i++) {
			if(a % i == 0 && b % i == 0) {
				Array[counter] = i;
				counter++;
			}
		}
		System.out.println(Array[counter - 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(), k = sc.nextInt();
		int [] Array = new int [50];
		int counter = 0;
		for(int i = 1; i <= a && i <= b; i++) {
			if(a % i == 0 && b % i == 0) {
				Array[counter] = i;
				counter++;
			}
		}
		System.out.println(Array[counter - k]);
		sc.close();
	}

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

}
