import java.util.Scanner;

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

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    }
} Main public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    } main {

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    } 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 cnt = 0; cnt 0 int small = Math.min(A, B); small Math.min(A, B) Math.min Math A B for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	} int i=small; int i=small; i small i>=1 i 1 i-- i-- i {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	} {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	} if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		} A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		} if(++cnt == K) {
    				System.out.println(i);
    				return;
    			} ++cnt == K ++cnt cnt K {
    				System.out.println(i);
    				return;
    			} System.out.println(i) System.out.println System.out System System.out i return; String[] args args public class Main {
    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    }
} public class Main {
    public static void main(String[] args) throws Exception {

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    }
} Main
import java.util.Scanner;

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

    	Scanner sc = new Scanner(System.in);

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

    	int cnt = 0;

    	int small = Math.min(A, B);
    	for(int i=small; i>=1; i--) {

    		if(A % i == 0 && B % i == 0){
    			if(++cnt == K) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    }
}