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

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	}
} 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 scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	} main {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		} int i = 1; int i = 1; i 1 i <= A i A i++ i++ i {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		} {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(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 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 scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	}
} Main

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

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int K = scan.nextInt();
		
		List<Integer> list = new ArrayList<>();
		for (int i = 1; i <= A; i++) {
			if ((A % i == 0) && (B % i == 0)) {
				list.add(i);
			}
		}
		
		System.out.println(list.get(list.size() - K));
		
		scan.close();
	}
}