import java.util.*;

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 maxAB = Math.max(a,b);
        int count = 0;
        int arrayCountAB = 0;

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                count++;
            }
        }

        Integer[] divisorAB = new Integer[count];

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        }

        Arrays.sort(divisorAB,Collections.reverseOrder());

        System.out.println(divisorAB[k-1]);

    }
} import java.util.*; util.* java 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 maxAB = Math.max(a,b);
        int count = 0;
        int arrayCountAB = 0;

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                count++;
            }
        }

        Integer[] divisorAB = new Integer[count];

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        }

        Arrays.sort(divisorAB,Collections.reverseOrder());

        System.out.println(divisorAB[k-1]);

    }
} 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 maxAB = Math.max(a,b);
        int count = 0;
        int arrayCountAB = 0;

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                count++;
            }
        }

        Integer[] divisorAB = new Integer[count];

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        }

        Arrays.sort(divisorAB,Collections.reverseOrder());

        System.out.println(divisorAB[k-1]);

    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int maxAB = Math.max(a,b);
        int count = 0;
        int arrayCountAB = 0;

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                count++;
            }
        }

        Integer[] divisorAB = new Integer[count];

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        }

        Arrays.sort(divisorAB,Collections.reverseOrder());

        System.out.println(divisorAB[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 maxAB = Math.max(a,b); maxAB Math.max(a,b) Math.max Math a b int count = 0; count 0 int arrayCountAB = 0; arrayCountAB 0 for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                count++;
            }
        } int i = 1; int i = 1; i 1 i <= maxAB i maxAB i++ i++ i {
            if(a % i == 0 && b % i == 0){
                count++;
            }
        } {
            if(a % i == 0 && b % i == 0){
                count++;
            }
        } if(a % i == 0 && b % i == 0){
                count++;
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                count++;
            } count++ count Integer[] divisorAB = new Integer[count]; divisorAB new Integer[count] count for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        } int i = 1; int i = 1; i 1 i <= maxAB i maxAB i++ i++ i {
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        } {
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        } if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            } divisorAB[arrayCountAB] = i divisorAB[arrayCountAB] divisorAB arrayCountAB i arrayCountAB++ arrayCountAB Arrays.sort(divisorAB,Collections.reverseOrder()) Arrays.sort Arrays divisorAB Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(divisorAB[k-1]) System.out.println System.out System System.out divisorAB[k-1] divisorAB k-1 k 1 String[] args args
import java.util.*;

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 maxAB = Math.max(a,b);
        int count = 0;
        int arrayCountAB = 0;

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                count++;
            }
        }

        Integer[] divisorAB = new Integer[count];

        for(int i = 1; i <= maxAB; i++){
            if(a % i == 0 && b % i == 0){
                divisorAB[arrayCountAB] = i;
                arrayCountAB++;
            }
        }

        Arrays.sort(divisorAB,Collections.reverseOrder());

        System.out.println(divisorAB[k-1]);

    }
}