import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	}
} import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	}
} Main public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	} main {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) int nam  = in.nextInt(); nam in.nextInt() in.nextInt in int nam2 = in.nextInt(); nam2 in.nextInt() in.nextInt in int min =  Math.min(nam,nam2); min Math.min(nam,nam2) Math.min Math nam nam2 int K    = in.nextInt(); K in.nextInt() in.nextInt in int KK[] = new int[min+1]; KK new int[min+1] min+1 min 1 int cnt = 0; cnt 0 for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        } int i = 1; int i = 1; i 1 i <= min i min i++ i++ i {
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        } {
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        } if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          } nam % i==0 && nam2 % i==0 nam % i==0 nam % i nam i 0 nam2 % i==0 nam2 % i nam2 i 0 {
        	cnt++;
          	KK[cnt] = i;
          } cnt++ cnt KK[cnt] = i KK[cnt] KK cnt i System.out.print(KK[cnt-K+1]) System.out.print System.out System System.out KK[cnt-K+1] KK cnt-K+1 cnt-K cnt K 1 String[] args args public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	}
} public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	}
} Main
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam  = in.nextInt();
      	int nam2 = in.nextInt();
      	int min =  Math.min(nam,nam2);
      	int K    = in.nextInt();
      	int KK[] = new int[min+1];
      
      int cnt = 0;
      for(int i = 1;i <= min ;i++){
        if(nam % i==0 && nam2 % i==0){
        	cnt++;
          	KK[cnt] = i;
          }
        }
      
  		System.out.print(KK[cnt-K+1]);
      
	}
}