import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    }
} Main public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    } main {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner ArrayList<Integer> ok = new ArrayList<>(); ok new ArrayList<>() for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        } int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        } {
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        } if(A%i ==0 && B%i==0){
                ok.add(i);
            } A%i ==0 && B%i==0 A%i ==0 A%i A i 0 B%i==0 B%i B i 0 {
                ok.add(i);
            } ok.add(i) ok.add ok i Collections.sort(ok, Comparator.reverseOrder()) Collections.sort Collections ok Comparator.reverseOrder() Comparator.reverseOrder Comparator System.out.println(ok.get(K-1)) System.out.println System.out System System.out ok.get(K-1) ok.get ok K-1 K 1 String[] args args public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    }
} public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int K = scanner.nextInt();

        ArrayList<Integer> ok = new ArrayList<>();

        for(int i=1; i<=100; i++){
            if(A%i ==0 && B%i==0){
                ok.add(i);
            }
        }

        Collections.sort(ok, Comparator.reverseOrder());

        System.out.println(ok.get(K-1));

    }
}