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();
		int buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	}
} 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();
		int buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	}
} 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 buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	} 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 buf = Math.min(A,B); buf Math.min(A,B) Math.min Math A B int count = 0; count 0 int ans = 0; ans 0 for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		} int i = 0; int i = 0; i 0 i < buf i buf i++ i++ i {
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		} {
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		} if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			} A % (buf - i) == 0 && B % (buf - i) == 0 A % (buf - i) == 0 A % (buf - i) A (buf - i) buf i 0 B % (buf - i) == 0 B % (buf - i) B (buf - i) buf i 0 {
				count++;
			} count++ count if(count == K){
				ans = buf - i;
				break;
			} count == K count K {
				ans = buf - i;
				break;
			} ans = buf - i ans buf - i buf i break; System.out.println(ans) System.out.println System.out System System.out ans 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 buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	}
} 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 buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	}
} 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();
		int buf = Math.min(A,B);
		int count = 0;
		int ans = 0;
		for(int i = 0;i < buf;i++){
			if(A % (buf - i) == 0 && B % (buf - i) == 0){
				count++;
			}
			if(count == K){
				ans = buf - i;
				break;
			}
		}
		System.out.println(ans);
	}
}