import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    }
} Main public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    } main {
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() 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 for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        } int i=1; int i=1; i 1 i<A+1 i A+1 A 1 i++ i++ i {
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        } {
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        } if(A%i==0 &&B%i==0){
            	list.add(i);
            } A%i==0 &&B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
            	list.add(i);
            } list.add(i) list.add list i Collections.reverse(list) Collections.reverse Collections list System.out.println(list.get(K-1)) System.out.println System.out System System.out list.get(K-1) list.get list K-1 K 1 String[] args args public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    }
} public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	ArrayList<Integer> list = new ArrayList<Integer>();
      	
		int A = sc.nextInt();
      	int B = sc.nextInt();
      	int K = sc.nextInt();
        for(int i=1;i<A+1;i++){
        	if(A%i==0 &&B%i==0){
            	list.add(i);
            }
        }
       Collections.reverse(list);
      	
          System.out.println(list.get(K-1)); 
        
		     
      
    }
}