import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	}
} Main public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	} main {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int a = scn.nextInt(); a scn.nextInt() scn.nextInt scn int b = scn.nextInt(); b scn.nextInt() scn.nextInt scn int k = scn.nextInt(); k scn.nextInt() scn.nextInt scn ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() int i = 1; i 1 do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a); i <= a i a {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} if (a % i == 0 && b % i == 0) {
				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 {
				list.add(i);
			} list.add(i) list.add list i i++ i System.out.println(list.get((list.size()-k))) System.out.println System.out System System.out list.get((list.size()-k)) list.get list (list.size()-k) list.size() list.size list k String args[] args public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	}
} public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	}
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	}
}