

import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	}

} import java.util.Scanner; Scanner java.util import java.util.Vector; Vector java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	} 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 Vector<Integer> vec = new Vector<Integer>(); vec new Vector<Integer>() for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		} int i = 1; int i = 1; i 1 i <= Math.min(a, b) i Math.min(a, b) Math.min Math a b i++ i++ i {
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		} {
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		} if(a%i == 0 && b%i == 0){
				vec.add(i);
			} a%i == 0 && b%i == 0 a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 {
				vec.add(i);
			} vec.add(i) vec.add vec i System.out.println(vec.get(vec.size() - k)) System.out.println System.out System System.out vec.get(vec.size() - k) vec.get vec vec.size() - k vec.size() vec.size vec k String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	}

} Main


import java.util.Scanner;
import java.util.Vector;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		Vector<Integer> vec = new Vector<Integer>();

		for(int i = 1; i <= Math.min(a, b); i++){
			if(a%i == 0 && b%i == 0){
				vec.add(i);
			}
		}

		System.out.println(vec.get(vec.size() - k));
	}

}
