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();

		List<Integer> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	}
	public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	}
} 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();

		List<Integer> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	}
	public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	}
} 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> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();

		List<Integer> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	} 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> aDivisor = new ArrayList<>(); aDivisor new ArrayList<>() List<Integer> bDivisor = new ArrayList<>(); bDivisor new ArrayList<>() for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		} int i = 1; int i = 1; i 1 i <= a i a i++ i++ i {
			if(a%i==0) {
				aDivisor.add(i);
			}
		} {
			if(a%i==0) {
				aDivisor.add(i);
			}
		} if(a%i==0) {
				aDivisor.add(i);
			} a%i==0 a%i a i 0 {
				aDivisor.add(i);
			} aDivisor.add(i) aDivisor.add aDivisor i for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		} int i = 1; int i = 1; i 1 i <= b i b i++ i++ i {
			if(b%i==0) {
				bDivisor.add(i);
			}
		} {
			if(b%i==0) {
				bDivisor.add(i);
			}
		} if(b%i==0) {
				bDivisor.add(i);
			} b%i==0 b%i b i 0 {
				bDivisor.add(i);
			} bDivisor.add(i) bDivisor.add bDivisor i Collections.sort(aDivisor, Collections.reverseOrder()) Collections.sort Collections aDivisor Collections.reverseOrder() Collections.reverseOrder Collections Collections.sort(bDivisor, Collections.reverseOrder()) Collections.sort Collections bDivisor Collections.reverseOrder() Collections.reverseOrder Collections int ans = 0; ans 0 if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		} aDivisor.size() < bDivisor.size() aDivisor.size() aDivisor.size aDivisor bDivisor.size() bDivisor.size bDivisor {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} ans =findKthDivisor(bDivisor, aDivisor, k) ans findKthDivisor(bDivisor, aDivisor, k) findKthDivisor bDivisor aDivisor k {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		} ans =findKthDivisor(aDivisor, bDivisor, k) ans findKthDivisor(aDivisor, bDivisor, k) findKthDivisor aDivisor bDivisor k System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	} findKthDivisor {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	} int count = 0; count 0 for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		} int div fewDivisor {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		} {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		} if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			} manyDivisor.contains(div) manyDivisor.contains manyDivisor div {
				count++;
				if(count == k) {
					return div;
				}
			} count++ count if(count == k) {
					return div;
				} count == k count k {
					return div;
				} return div; div return 0; 0 List<Integer> manyDivisor manyDivisor List<Integer> fewDivisor fewDivisor int k 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();

		List<Integer> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	}
	public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	}
} 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> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	}
	public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	}
} 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();

		List<Integer> aDivisor = new ArrayList<>();
		List<Integer> bDivisor = new ArrayList<>();
		for(int i = 1; i <= a; i++) {
			if(a%i==0) {
				aDivisor.add(i);
			}
		}
		for(int i = 1; i <= b; i++) {
			if(b%i==0) {
				bDivisor.add(i);
			}
		}
		// 降順
		Collections.sort(aDivisor, Collections.reverseOrder());
		Collections.sort(bDivisor, Collections.reverseOrder());
		int ans = 0;
		if(aDivisor.size() < bDivisor.size()) {
			ans =findKthDivisor(bDivisor, aDivisor, k);
		} else {
			ans =findKthDivisor(aDivisor, bDivisor, k);
		}
		System.out.println(ans);

	}
	public static int findKthDivisor(List<Integer> manyDivisor, List<Integer> fewDivisor, int k) {
		int count = 0;
		for(int div : fewDivisor) {
			if(manyDivisor.contains(div)) {
				count++;
				if(count == k) {
					return div;
				}
			}
		}
		return 0;
	}
}
