import java.util.*;
import java.util.Collections;

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

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