import java.util.ArrayList;
import java.util.Collections;
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();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections 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();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	}
} 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();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	} 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 sc.close() sc.close sc List<Integer> ary = new ArrayList<>(); ary new ArrayList<>() int flg = 1; flg 1 while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		} flg <= A || flg <= B flg <= A flg A flg <= B flg B {
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		} if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			} A%flg==0&&B%flg==0 A%flg==0 A%flg A flg 0 B%flg==0 B%flg B flg 0 {
				ary.add(flg);
			} ary.add(flg) ary.add ary flg flg++ flg Collections.sort(ary, Collections.reverseOrder()) Collections.sort Collections ary Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(ary.get(K-1)) System.out.println System.out System System.out ary.get(K-1) ary.get ary K-1 K 1 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();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	}
} 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();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
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();
		sc.close();
		List<Integer> ary = new ArrayList<>();
		int flg = 1;
		while(flg <= A || flg <= B){
			if(A%flg==0&&B%flg==0) {
				ary.add(flg);
			}
			flg++;
		}
		Collections.sort(ary, Collections.reverseOrder());
		System.out.println(ary.get(K-1));
	}
}