import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	}
} import java.util.*; util.* java public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	}
} Main public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	} main {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	} Scanner keyboard = new Scanner(System.in); keyboard new Scanner(System.in) int A  = keyboard.nextInt(); A keyboard.nextInt() keyboard.nextInt keyboard int B  = keyboard.nextInt(); B keyboard.nextInt() keyboard.nextInt keyboard int K  = keyboard.nextInt(); K keyboard.nextInt() keyboard.nextInt keyboard int N = A < B ? A : B; N A < B ? A : B A < B A B A B int[] ans = new int[N+1]; ans new int[N+1] N+1 N 1 for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		} int i=1; int i=1; i 1 i<N+1 i N+1 N 1 i++ i++ i {
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		} {
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		} int a = A % i; a A % i A i int b = B % i; b B % i B i if(a == 0 && b == 0){
				ans[i] = i;
			} a == 0 && b == 0 a == 0 a 0 b == 0 b 0 {
				ans[i] = i;
			} ans[i] = i ans[i] ans i i Arrays.sort(ans) Arrays.sort Arrays ans for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		} int j=N; int j=N; j N j>=0 j 0 j-- j-- j {
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		} {
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		} if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			} N-j +1 == K N-j +1 N-j N j 1 K {
				System.out.println(ans[j]) ;
				break;
			} System.out.println(ans[j]) System.out.println System.out System System.out ans[j] ans j break; keyboard.close() keyboard.close keyboard String[] args args public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	}
} public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	}
} Main
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int A  = keyboard.nextInt();
		int B  = keyboard.nextInt();
		int K  = keyboard.nextInt();
		
		int N = A < B ? A : B;
		int[] ans = new int[N+1];
		
		for(int i=1; i<N+1; i++){
			int a = A % i;
			int b = B % i;
			if(a == 0 && b == 0){
				ans[i] = i;
			}
		}
		
		Arrays.sort(ans); 
		for(int j=N; j>=0; j--){
			if(N-j +1 == K){
				System.out.println(ans[j]) ;
				break;
			}
		}
		keyboard.close();	
	}
}