import java.util.Scanner;


public class Main{

    public static void main(String []args){
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{

    public static void main(String []args){
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    }
} Main public static void main(String []args){
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    } main {
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan int count = 0; count 0 int ans = 0; ans 0 int N = 0; N 0 for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        } int i=1; int i=1; i 1 i<=Math.min(A,B) i Math.min(A,B) Math.min Math A B i++ i++ i {
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        } {
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        } if(A%i ==0 && B%i==0){
                N += 1;
            } A%i ==0 && B%i==0 A%i ==0 A%i A i 0 B%i==0 B%i B i 0 {
                N += 1;
            } N += 1 N 1 K = N-K+1 K N-K+1 N-K N K 1 for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        } int i=1; int i=1; i 1 count<K count K i++ i++ i {
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        } {
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        } if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            } A%i ==0 && B%i==0 A%i ==0 A%i A i 0 B%i==0 B%i B i 0 {
                ans = i;
                count += 1;
            } ans = i ans i count += 1 count 1 System.out.println(ans) System.out.println System.out System System.out ans scan.close() scan.close scan String []args args public class Main{

    public static void main(String []args){
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    }
} public class Main{

    public static void main(String []args){
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    }
} Main
import java.util.Scanner;


public class Main{

    public static void main(String []args){
       Scanner scan = new Scanner(System.in);
       int A = scan.nextInt();
       int B = scan.nextInt();
       int K = scan.nextInt();

        int count = 0;
        int ans = 0;

        int N = 0;
        
        for(int i=1; i<=Math.min(A,B); i++){
            if(A%i ==0 && B%i==0){
                N += 1;
            }
        }

        K = N-K+1;

        for(int i=1; count<K; i++){
            if(A%i ==0 && B%i==0){
                ans = i;
                count += 1;
            }
        }
        System.out.println(ans);
   
       scan.close();
    }
}