import java.util.*;
import java.io.*;
class Program{

}
class Main{
    public static void main(String args[]) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt();
    int small = Math.min(A,B), big = Math.max(A,B);
    ArrayList <Integer> fact = new ArrayList<Integer>();
    for(int i = 1;i<=(int)Math.sqrt(small);i++){
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    }
    Collections.sort(fact);
    Collections.reverse(fact);
    //System.out.println(fact);
    System.out.println(fact.get(K-1));
    }
}
 import java.util.*; util.* java import java.io.*; io.* java class Program{

} Program class Main{
    public static void main(String args[]) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt();
    int small = Math.min(A,B), big = Math.max(A,B);
    ArrayList <Integer> fact = new ArrayList<Integer>();
    for(int i = 1;i<=(int)Math.sqrt(small);i++){
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    }
    Collections.sort(fact);
    Collections.reverse(fact);
    //System.out.println(fact);
    System.out.println(fact.get(K-1));
    }
} Main public static void main(String args[]) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt();
    int small = Math.min(A,B), big = Math.max(A,B);
    ArrayList <Integer> fact = new ArrayList<Integer>();
    for(int i = 1;i<=(int)Math.sqrt(small);i++){
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    }
    Collections.sort(fact);
    Collections.reverse(fact);
    //System.out.println(fact);
    System.out.println(fact.get(K-1));
    } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt();
    int small = Math.min(A,B), big = Math.max(A,B);
    ArrayList <Integer> fact = new ArrayList<Integer>();
    for(int i = 1;i<=(int)Math.sqrt(small);i++){
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    }
    Collections.sort(fact);
    Collections.reverse(fact);
    //System.out.println(fact);
    System.out.println(fact.get(K-1));
    } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt() A sc.nextInt() sc.nextInt sc B = sc.nextInt() B sc.nextInt() sc.nextInt sc K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int small = Math.min(A,B) small Math.min(A,B) Math.min Math A B big = Math.max(A,B); big Math.max(A,B) Math.max Math A B ArrayList <Integer> fact = new ArrayList<Integer>(); fact new ArrayList<Integer>() for(int i = 1;i<=(int)Math.sqrt(small);i++){
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    } int i = 1; int i = 1; i 1 i<=(int)Math.sqrt(small) i (int)Math.sqrt(small) Math.sqrt Math small i++ i++ i {
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    } {
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    } if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        } small%i==0 small%i small i 0 {
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        } if(big%i==0){
                fact.add(i);
            } big%i==0 big%i big i 0 {
                fact.add(i);
            } fact.add(i) fact.add fact i if (big%(small/i)==0 && i!=small/i) fact.add(small/i); big%(small/i)==0 && i!=small/i big%(small/i)==0 big%(small/i) big (small/i) small i 0 i!=small/i i small/i small i fact.add(small/i) fact.add fact small/i small i Collections.sort(fact) Collections.sort Collections fact Collections.reverse(fact) Collections.reverse Collections fact System.out.println(fact.get(K-1)) System.out.println System.out System System.out fact.get(K-1) fact.get fact K-1 K 1 String args[] args
import java.util.*;
import java.io.*;
class Program{

}
class Main{
    public static void main(String args[]) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt(), B = sc.nextInt(), K = sc.nextInt();
    int small = Math.min(A,B), big = Math.max(A,B);
    ArrayList <Integer> fact = new ArrayList<Integer>();
    for(int i = 1;i<=(int)Math.sqrt(small);i++){
        if (small%i==0){
            if(big%i==0){
                fact.add(i);
            }
            if (big%(small/i)==0 && i!=small/i) fact.add(small/i);
            
        }
    }
    Collections.sort(fact);
    Collections.reverse(fact);
    //System.out.println(fact);
    System.out.println(fact.get(K-1));
    }
}

