import java.util.ArrayList;
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();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.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 sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.size() - 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();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.size() - K));

	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.size() - 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 ArrayList<Integer> ary = new ArrayList<Integer>(); ary new ArrayList<Integer>() for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		} int i = 1; int i = 1; i 1 i < 101 i 101 i++ i++ i {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		} {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		} if (A % i == 0 && B % i == 0) {
				ary.add(i);
			} A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
				ary.add(i);
			} ary.add(i) ary.add ary i System.out.println(ary.get(ary.size() - K)) System.out.println System.out System System.out ary.get(ary.size() - K) ary.get ary ary.size() - K ary.size() ary.size ary 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();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.size() - 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();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.size() - K));

	}
} Main
import java.util.ArrayList;
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();

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

		for (int i = 1; i < 101; i++) {
			if (A % i == 0 && B % i == 0) {
				ary.add(i);
			}
		}

		System.out.println(ary.get(ary.size() - K));

	}
}
