import java.util.*;
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 max = a;
		if( a < b ) {
			max = b;
		}
		int flag = 0;
		for(int i = max; i > 0; i--) {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		}
	}
} import java.util.*; util.* java 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 max = a;
		if( a < b ) {
			max = b;
		}
		int flag = 0;
		for(int i = max; i > 0; i--) {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		}
	}
} 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 max = a;
		if( a < b ) {
			max = b;
		}
		int flag = 0;
		for(int i = max; i > 0; i--) {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		int max = a;
		if( a < b ) {
			max = b;
		}
		int flag = 0;
		for(int i = max; i > 0; i--) {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		}
	} 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 max = a; max a if( a < b ) {
			max = b;
		} a < b a b {
			max = b;
		} max = b max b int flag = 0; flag 0 for(int i = max; i > 0; i--) {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		} int i = max; int i = max; i max i > 0 i 0 i-- i-- i {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		} {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		} if( a%i == 0 && b%i == 0 ) {
				flag++;
			} a%i == 0 && b%i == 0 a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 {
				flag++;
			} flag++ flag if(flag == k) {
				System.out.println(i);
				break;
			} flag == k flag k {
				System.out.println(i);
				break;
			} System.out.println(i) System.out.println System.out System System.out i break; String[] args args
import java.util.*;
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 max = a;
		if( a < b ) {
			max = b;
		}
		int flag = 0;
		for(int i = max; i > 0; i--) {
			if( a%i == 0 && b%i == 0 ) {
				flag++;
			}
			if(flag == k) {
				System.out.println(i);
				break;
			}
		}
	}
}