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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	} main {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) Long A = Long.parseLong(sc.next()); A Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc Long B = Long.parseLong(sc.next()); B Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		} int i = 1; int i = 1; i 1 i <= 100 i 100 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 Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(list.get(K - 1)) System.out.println System.out System System.out list.get(K - 1) list.get list K - 1 K 1 String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	}
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long A = Long.parseLong(sc.next());
		Long B = Long.parseLong(sc.next());
		int K = Integer.parseInt(sc.next());
		sc.close();
		ArrayList<Integer> list = new ArrayList<Integer>();

		for(int i = 1; i <= 100 ; i++) {
			if(A % i == 0 && B % i == 0) {
				list.add(i);
			}
		}
		Collections.sort(list, Collections.reverseOrder());
		System.out.println(list.get(K - 1));
	}
}