import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    }
} Main public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    } main {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    } Scanner sn = new Scanner(System.in); sn new Scanner(System.in) int a = sn.nextInt(); a sn.nextInt() sn.nextInt sn int b = sn.nextInt(); b sn.nextInt() sn.nextInt sn int k = sn.nextInt(); k sn.nextInt() sn.nextInt sn List<Integer> commonDiviserList = new ArrayList<>(); commonDiviserList new ArrayList<>() int c = a > b ? b : a; c a > b ? b : a a > b a b b a for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        } int i = c; int i = c; i c i >= 1 i 1 i-- i-- i {
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        } {
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        } if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                commonDiviserList.add(i);
            } commonDiviserList.add(i) commonDiviserList.add commonDiviserList i System.out.println(commonDiviserList.get(k - 1)) System.out.println System.out System System.out commonDiviserList.get(k - 1) commonDiviserList.get commonDiviserList k - 1 k 1 String[] args args public class Main {

    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    }
} public class Main {

    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sn = new Scanner(System.in);
        int a = sn.nextInt();
        int b = sn.nextInt();
        int k = sn.nextInt();
        
        List<Integer> commonDiviserList = new ArrayList<>();
        int c = a > b ? b : a;
        for (int i = c; i >= 1; i--){
            if(a % i == 0 && b % i == 0){
                commonDiviserList.add(i);
            }
        }
        
        System.out.println(commonDiviserList.get(k - 1));        
    }
}