import java.util.*;

class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int n = sc.nextInt();

        int s = 0;
        int k= 0;
            for(int i=100;i>=0;i--){
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            }
            System.out.println(s); 
     }
} import java.util.*; util.* java class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int n = sc.nextInt();

        int s = 0;
        int k= 0;
            for(int i=100;i>=0;i--){
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            }
            System.out.println(s); 
     }
} Main public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int n = sc.nextInt();

        int s = 0;
        int k= 0;
            for(int i=100;i>=0;i--){
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            }
            System.out.println(s); 
     } main {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int n = sc.nextInt();

        int s = 0;
        int k= 0;
            for(int i=100;i>=0;i--){
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            }
            System.out.println(s); 
     } 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 n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int s = 0; s 0 int k= 0; k 0 for(int i=100;i>=0;i--){
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            } int i=100; int i=100; i 100 i>=0 i 0 i-- i-- i {
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            } {
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            } if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                } (A%i==0)&&(B%i==0) (A%i==0) A%i A i 0 (B%i==0) B%i B i 0 {
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                } s=i s i k++ k if(k==n){   
                        break;
                    } k==n k n {   
                        break;
                    } break; System.out.println(s) System.out.println System.out System System.out s String[] args args
import java.util.*;

class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int n = sc.nextInt();

        int s = 0;
        int k= 0;
            for(int i=100;i>=0;i--){
                if((A%i==0)&&(B%i==0)){
                    s=i;     
                    k++;        
                    if(k==n){   
                        break;
                    }
                }
            }
            System.out.println(s); 
     }
}