import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	}
} import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import java.math.BigInteger; BigInteger java.math 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();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	}
} 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();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	} main {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	} 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 int result = 0; result 0 int c = min(a, b); c min(a, b) min a b for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		} int i = c; int i = c; i c i > 0 i 0 i-- i-- i {
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		} {
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		} if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    } a%i == 0 && b%i == 0 a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 {
		        k--;
		        result = i;
		        if(k == 0) break;
		    } k-- k result = i result i if(k == 0) break; k == 0 k 0 break; System.out.println(result) System.out.println System.out System System.out result 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();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	}
} 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();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	}
} Main
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

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();
		
		// 計算
		int result = 0;
		int c = min(a, b);
		for(int i = c; i > 0; i--){
		    if(a%i == 0 && b%i == 0){
		        k--;
		        result = i;
		        if(k == 0) break;
		    }
		}

		// 出力
		System.out.println(result);
        
	}
}
