import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    }
} Main public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    } main {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        } int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        } {
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        } if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            } 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);
                count++;
            } list.add(i) list.add list i count++ count Collections.sort(list, Collections.reverseOrder()) Collections.sort Collections list Collections.reverseOrder() Collections.reverseOrder Collections 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) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();
        int count = 0;
        
        List<Integer> list = new ArrayList<Integer>();
        for(int i=1; i<=100; i++){
            if(A%i==0 && B%i==0){
                list.add(i);
                count++;
            }
        }
        
        Collections.sort(list, Collections.reverseOrder());
        
        System.out.println(list.get(K-1));
        
    }
}
