import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.size()-K));
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.size()-K));
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.size()-K));
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.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 ArrayList<Integer> al = new ArrayList<>(); al new ArrayList<>() Integer min = A; min A if(A>B){
          min = B;
        } A>B A B {
          min = B;
        } min = B min B for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        } int i = 1; int i = 1; i 1 i < min+1 i min+1 min 1 i++ i++ i {
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        } {
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        } if((A%i==0)&&(B%i==0)){
              al.add(i);
            } (A%i==0)&&(B%i==0) (A%i==0) A%i A i 0 (B%i==0) B%i B i 0 {
              al.add(i);
            } al.add(i) al.add al i System.out.println(al.get(al.size()-K)) System.out.println System.out System System.out al.get(al.size()-K) al.get al al.size()-K al.size() al.size al K String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.size()-K));
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.size()-K));
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
      
		ArrayList<Integer> al = new ArrayList<>();
      
      	Integer min = A;
      	if(A>B){
          min = B;
        }
      	for(int i = 1; i < min+1; i++){
          	if((A%i==0)&&(B%i==0)){
              al.add(i);
            }
        }
		System.out.println(al.get(al.size()-K));
	}
}