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();


    ArrayList<Integer>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.get(K-1));
 }
} 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();


    ArrayList<Integer>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.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>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.get(K-1));
 } main {
    
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();


    ArrayList<Integer>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.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>onaji = new ArrayList<>(); onaji new ArrayList<>() int cou = 0; cou 0 int max = Math.max(A,B); max Math.max(A,B) Math.max Math A B for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
} int i=1; int i=1; i 1 i<=max i max i++ i++ i {
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
} {
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
} if(A%i==0 && B%i==0){
        onaji.add(i);
} A%i==0 && B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
        onaji.add(i);
} onaji.add(i) onaji.add onaji i Collections.sort(onaji, Collections.reverseOrder()) Collections.sort Collections onaji Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(onaji.get(K-1)) System.out.println System.out System System.out onaji.get(K-1) onaji.get onaji K-1 K 1 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>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.get(K-1));
 }
} 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>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.get(K-1));
 }
} 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();


    ArrayList<Integer>onaji = new ArrayList<>();
    int cou = 0;    
    int max = Math.max(A,B); 
    for(int i=1; i<=max; i++){
        if(A%i==0 && B%i==0){
        onaji.add(i);
}
}
    Collections.sort(onaji, Collections.reverseOrder());
        System.out.println(onaji.get(K-1));
 }
}