import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
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> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	}
 
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner 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> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	}
 
} 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> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		
	
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		
		ArrayList<Integer> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	} 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> div = new ArrayList<>(); div new ArrayList<>() int c = Math.min(a, b); c Math.min(a, b) Math.min Math a b for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		} int i = 1; int i = 1; i 1 i <= c i c i++ i++ i {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		} {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		} if((a % i == 0) && (b % i == 0)) div.add(i); (a % i == 0) && (b % i == 0) (a % i == 0) a % i a i 0 (b % i == 0) b % i b i 0 div.add(i) div.add div i Collections.sort(div, Collections.reverseOrder()) Collections.sort Collections div Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(div.get(k-1)) System.out.println System.out System System.out div.get(k-1) div.get div k-1 k 1 sc.close() sc.close sc 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> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	}
 
} 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> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	}
 
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
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> div = new ArrayList<>();
		
		int c = Math.min(a, b);
		for(int i = 1; i <= c; i++) {
			if((a % i == 0) && (b % i == 0)) div.add(i);
		}
		
		Collections.sort(div, Collections.reverseOrder());
		System.out.println(div.get(k-1));
		
		sc.close();
	}
 
}
