import java.util.ArrayList;
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();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.size()-k));
	}
	
	public static List<Integer> method1(int a) {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	}
} 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 sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.size()-k));
	}
	
	public static List<Integer> method1(int a) {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	}
} 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();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.size()-k));
	} main {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.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 List<Integer> aList = method1(a); aList method1(a) method1 a List<Integer> bList = method1(b); bList method1(b) method1 b List<Integer> ansList = new ArrayList<>(); ansList new ArrayList<>() for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		} Integer d aList {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		} {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		} for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			} Integer e bList {
				if (d.equals(e)) {
					ansList.add(e);
				}
			} {
				if (d.equals(e)) {
					ansList.add(e);
				}
			} if (d.equals(e)) {
					ansList.add(e);
				} d.equals(e) d.equals d e {
					ansList.add(e);
				} ansList.add(e) ansList.add ansList e System.out.println(ansList.get(ansList.size()-k)) System.out.println System.out System System.out ansList.get(ansList.size()-k) ansList.get ansList ansList.size()-k ansList.size() ansList.size ansList k String[] args args public static List<Integer> method1(int a) {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	} method1 {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	} List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		} int i=1; int i=1; i 1 i<=a i a i++ i++ i {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		} {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		} if (a%i==0) {
				list.add(Integer.valueOf(i));
			} a%i==0 a%i a i 0 {
				list.add(Integer.valueOf(i));
			} list.add(Integer.valueOf(i)) list.add list Integer.valueOf(i) Integer.valueOf Integer i return list; list int a a 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();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.size()-k));
	}
	
	public static List<Integer> method1(int a) {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	}
} 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();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.size()-k));
	}
	
	public static List<Integer> method1(int a) {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	}
} Main
import java.util.ArrayList;
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();
		
		List<Integer> aList = method1(a);
		List<Integer> bList = method1(b);
		
		List<Integer> ansList = new ArrayList<>();
		
		for (Integer d: aList) {
			for(Integer e: bList) {
				if (d.equals(e)) {
					ansList.add(e);
				}
			}
		}
		System.out.println(ansList.get(ansList.size()-k));
	}
	
	public static List<Integer> method1(int a) {
		List<Integer> list = new ArrayList<>();
		for(int i=1; i<=a; i++) {
			if (a%i==0) {
				list.add(Integer.valueOf(i));
			}
		}
		return list;
	}
}