import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    } main {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    } 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 ans = 1; ans 1 int count = 0; count 0 int i = 101; i 101 while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        } count < K count K {
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        } i-- i if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            } 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++;
            } ans = i ans i count++ count System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

        int ans = 1;
        int count = 0;
        int i = 101;
        while(count < K){
            i--; 
            if( A % i == 0 && B % i == 0){
                ans = i;
                count++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        

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