import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
} import java.util.Iterator; Iterator java.util import java.util.Scanner; Scanner java.util import java.util.TreeSet; TreeSet java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() 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 int ans = 0; ans 0 TreeSet<Integer> ts = new TreeSet<>(); ts new TreeSet<>() while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		} ans <= Math.min(a, b) ans Math.min(a, b) Math.min Math a b {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		} ans++ ans if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			} a % ans == 0 && b % ans == 0 a % ans == 0 a % ans a ans 0 b % ans == 0 b % ans b ans 0 {
				ts.add(ans);
			} ts.add(ans) ts.add ts ans Iterator<Integer> ite = ts.iterator(); ite ts.iterator() ts.iterator ts for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		} int i = 0; int i = 0; i 0 i < ts.size() - k i ts.size() - k ts.size() ts.size ts k i++ i++ i {
			ite.next();
		} {
			ite.next();
		} ite.next() ite.next ite System.out.println(ite.next()) System.out.println System.out System System.out ite.next() ite.next ite String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
} Main
import java.util.Iterator;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int ans = 0;
		TreeSet<Integer> ts = new TreeSet<>();
		while (ans <= Math.min(a, b)) {
			ans++;
			if (a % ans == 0 && b % ans == 0) {
				ts.add(ans);
			}
		}
		Iterator<Integer> ite = ts.iterator();
		for (int i = 0; i < ts.size() - k; i++) {
			ite.next();
		}
		System.out.println(ite.next());
	}
}
