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();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - K]);
	}
} 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();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - K]);
	}
} 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();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - K]);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - 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 int countA = 0; countA 0 int countB = 0; countB 0 int[] Ayaku = new int[A + 1]; Ayaku new int[A + 1] A + 1 A 1 int[] Byaku = new int[B + 1]; Byaku new int[B + 1] B + 1 B 1 int[] yaku = new int[A + 1]; yaku new int[A + 1] A + 1 A 1 for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		} int i = 1; int i = 1; i 1 i <= A i A i++ i++ i {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		} {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		} if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			} A % i == 0 A % i A i 0 {
				countA++;
				Ayaku[countA] = i;
			} countA++ countA Ayaku[countA] = i Ayaku[countA] Ayaku countA i for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		} int i = 1; int i = 1; i 1 i <= B i B i++ i++ i {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		} {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		} if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			} B % i == 0 B % i B i 0 {
				countB++;
				Byaku[countB] = i;
			} countB++ countB Byaku[countB] = i Byaku[countB] Byaku countB i int countK = 0; countK 0 for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		} int i = 1; int i = 1; i 1 i <= countA i countA i++ i++ i {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		} {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		} for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			} int j = 1; int j = 1; j 1 j <= countB j countB j++ j++ j {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			} {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			} if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				} Ayaku[i] == Byaku[j] Ayaku[i] Ayaku i Byaku[j] Byaku j {
					countK++;
					yaku[countK] = Ayaku[i];
				} countK++ countK yaku[countK] = Ayaku[i] yaku[countK] yaku countK Ayaku[i] Ayaku i System.out.println(yaku[countK + 1 - K]) System.out.println System.out System System.out yaku[countK + 1 - K] yaku countK + 1 - K countK + 1 countK 1 K 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();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - 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();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - K]);
	}
} Main
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();
		
		int countA = 0;
		int countB = 0;
		int[] Ayaku = new int[A + 1];
		int[] Byaku = new int[B + 1];
		int[] yaku = new int[A + 1];
		
		for(int i = 1; i <= A; i++) {
			if(A % i == 0) {
				countA++;
				Ayaku[countA] = i;
			}
		}
		
		for(int i = 1; i <= B; i++) {
			if(B % i == 0) {
				countB++;
				Byaku[countB] = i;
			}
		}
		int countK = 0;
		for(int i = 1; i <= countA; i++) {
			for(int j = 1; j <= countB; j++) {
				if(Ayaku[i] == Byaku[j]) {
					countK++;
					yaku[countK] = Ayaku[i];
				}
			}
		}
		System.out.println(yaku[countK + 1 - K]);
	}
}
