import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int order = sc.nextInt();

        int cnt = 0, div = Math.min(num1, num2) + 1;
        while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        }
        System.out.println(div);
    }
} import java.util.Scanner; Scanner java.util class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int order = sc.nextInt();

        int cnt = 0, div = Math.min(num1, num2) + 1;
        while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        }
        System.out.println(div);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int order = sc.nextInt();

        int cnt = 0, div = Math.min(num1, num2) + 1;
        while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        }
        System.out.println(div);
    } main {
        Scanner sc = new Scanner(System.in);

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int order = sc.nextInt();

        int cnt = 0, div = Math.min(num1, num2) + 1;
        while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        }
        System.out.println(div);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num1 = sc.nextInt(); num1 sc.nextInt() sc.nextInt sc int num2 = sc.nextInt(); num2 sc.nextInt() sc.nextInt sc int order = sc.nextInt(); order sc.nextInt() sc.nextInt sc int cnt = 0 cnt 0 div = Math.min(num1, num2) + 1; div Math.min(num1, num2) + 1 Math.min(num1, num2) Math.min Math num1 num2 1 while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        } cnt < order cnt order {
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        } div-- div if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            } num1 % div == 0 && num2 % div == 0 num1 % div == 0 num1 % div num1 div 0 num2 % div == 0 num2 % div num2 div 0 {
                cnt++;
            } cnt++ cnt System.out.println(div) System.out.println System.out System System.out div String[] args args
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int num1 = sc.nextInt();
        int num2 = sc.nextInt();
        int order = sc.nextInt();

        int cnt = 0, div = Math.min(num1, num2) + 1;
        while(cnt < order){
            div--;
            if(num1 % div == 0 && num2 % div == 0){
                cnt++;
            }
        }
        System.out.println(div);
    }
}