import java.util.ArrayList;
import java.util.List;
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();
		int counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	}

} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util 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();
		int counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	}

} 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 counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	} 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 counter = 0; counter 0 List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		} 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) {
				counter++;
				list.add(i);
			}
		} {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		} if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			} a%i == 0 && b%i == 0 a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 {
				counter++;
				list.add(i);
			} counter++ counter list.add(i) list.add list i System.out.println(list.get(counter - k)) System.out.println System.out System System.out list.get(counter - k) list.get list counter - k counter k 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 counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	}

} 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 counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	}

} Main
import java.util.ArrayList;
import java.util.List;
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();
		int counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	}

}
