import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) throws Exception {

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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 {

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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 {

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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;
	    			}
	    		}
	    	}
    	}
    } try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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;
	    			}
	    		}
	    	}
    	} {

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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;
	    			}
	    		}
	    	}
    	} BufferedReader r = new BufferedReader(new InputStreamReader(System.in)) BufferedReader r = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) String line = r.readLine(); line r.readLine() r.readLine r String[] vals = line.split(" "); vals line.split(" ") line.split line " " int A = Integer.parseInt(vals[0]); A Integer.parseInt(vals[0]) Integer.parseInt Integer vals[0] vals 0 int B = Integer.parseInt(vals[1]); B Integer.parseInt(vals[1]) Integer.parseInt Integer vals[1] vals 1 int K = Integer.parseInt(vals[2]); K Integer.parseInt(vals[2]) Integer.parseInt Integer vals[2] vals 2 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 {

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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 {

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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.io.BufferedReader;
import java.io.InputStreamReader;

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

    	try(BufferedReader r = new BufferedReader(new InputStreamReader(System.in))){

    		String line = r.readLine();
    		String[] vals = line.split(" ");

    		int A = Integer.parseInt(vals[0]);
    		int B = Integer.parseInt(vals[1]);
    		int K = Integer.parseInt(vals[2]);
	    	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;
	    			}
	    		}
	    	}
    	}
    }
}