import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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> array = new ArrayList<>();

       	for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	}
       	Collections.sort(array, Comparator.reverseOrder());

       	System.out.println(array.get(K-1));

}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner 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();
       	ArrayList<Integer> array = new ArrayList<>();

       	for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	}
       	Collections.sort(array, Comparator.reverseOrder());

       	System.out.println(array.get(K-1));

}
} 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> array = new ArrayList<>();

       	for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	}
       	Collections.sort(array, Comparator.reverseOrder());

       	System.out.println(array.get(K-1));

} main {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
       	int B =sc.nextInt();
       	int K =sc.nextInt();
       	ArrayList<Integer> array = new ArrayList<>();

       	for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	}
       	Collections.sort(array, Comparator.reverseOrder());

       	System.out.println(array.get(K-1));

} 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> array = new ArrayList<>(); array new ArrayList<>() for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	} int i =1 ; int i =1 ; i 1 i<=100 i 100 i++ i++ i {
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	} {
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	} if(A %i ==0 & B%i ==0){
       			array.add(i);
       		} A %i ==0 & B%i ==0 A %i ==0 A %i A i 0 B%i ==0 B%i B i 0 {
       			array.add(i);
       		} array.add(i) array.add array i Collections.sort(array, Comparator.reverseOrder()) Collections.sort Collections array Comparator.reverseOrder() Comparator.reverseOrder Comparator System.out.println(array.get(K-1)) System.out.println System.out System System.out array.get(K-1) array.get array K-1 K 1 String[] args args
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

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> array = new ArrayList<>();

       	for(int i =1 ;i<=100;i++){
       		if(A %i ==0 & B%i ==0){
       			array.add(i);
       		}
       	}
       	Collections.sort(array, Comparator.reverseOrder());

       	System.out.println(array.get(K-1));

}
}
