
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {

	public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util public class Main {

	public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

} Main public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	} run {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String line = br.readLine(); line br.readLine() br.readLine br List<Integer> arrayData = new ArrayList<Integer>(); arrayData new ArrayList<Integer>() String[] lineArray = line.split(" "); lineArray line.split(" ") line.split line " " for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		} String token lineArray {
			arrayData.add(Integer.parseInt(token));
		} {
			arrayData.add(Integer.parseInt(token));
		} arrayData.add(Integer.parseInt(token)) arrayData.add arrayData Integer.parseInt(token) Integer.parseInt Integer token int A = arrayData.get(0); A arrayData.get(0) arrayData.get arrayData 0 int B = arrayData.get(1); B arrayData.get(1) arrayData.get arrayData 1 int K = arrayData.get(2); K arrayData.get(2) arrayData.get arrayData 2 List<Integer> li = new ArrayList<Integer>(); li new ArrayList<Integer>() int smaller = Math.min(A, B); smaller Math.min(A, B) Math.min Math A B for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		} int i=1; int i=1; i 1 i<=smaller i smaller i++ i++ i {
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		} {
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		} if(A%i == 0 && B%i == 0){
					li.add(i);
				} A%i == 0 && B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 {
					li.add(i);
				} li.add(i) li.add li i Collections.reverse(li) Collections.reverse Collections li System.out.println(li.get(K-1)) System.out.println System.out System System.out li.get(K-1) li.get li K-1 K 1 public static void main(String[] args) throws Exception {
        new Main().run();
    } main {
        new Main().run();
    } new Main().run() new Main().run new Main() String[] args args public class Main {

	public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

} public class Main {

	public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

} Main

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {

	public void run() throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		List<Integer> arrayData = new ArrayList<Integer>();
		String[] lineArray = line.split(" ");
		for (String token : lineArray) {
			arrayData.add(Integer.parseInt(token));
		}
		int A = arrayData.get(0);
		int B = arrayData.get(1);
		int K = arrayData.get(2);
		List<Integer> li = new ArrayList<Integer>();
		int smaller = Math.min(A, B);
		for(int i=1; i<=smaller;i++){
	
				if(A%i == 0 && B%i == 0){
					li.add(i);
				}

		}
		
		Collections.reverse(li);
		System.out.println(li.get(K-1));
	}
    public static void main(String[] args) throws Exception {
        new Main().run();
    }

}