

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    } 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 min = Math.min(A,B); min Math.min(A,B) Math.min Math A B int count = 0; count 0 int val = 0; val 0 for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        } int i = min; int i = min; i min i >= 1 i 1 i-- i-- i {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        } {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        } if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            } A%i==0 && B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
                count++;
                val = i;
                if(count == k) break;
            } count++ count val = i val i if(count == k) break; count == k count k break; System.out.println(val) System.out.println System.out System System.out val String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    }
} Main


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int k = sc.nextInt();
        int min = Math.min(A,B);
        int count = 0;
        int val = 0;

        for(int i = min; i >= 1; i--) {
            if(A%i==0 && B%i==0){
                count++;
                val = i;
                if(count == k) break;
            }
        }
        System.out.println(val);
    }
}
