import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int count =0; count 0 int i=b+1; i b+1 b 1 while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        } count<k count k {
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        } i-- i if((a%i==0)&&(b%i==0)) count++; (a%i==0)&&(b%i==0) (a%i==0) a%i a i 0 (b%i==0) b%i b i 0 count++ count System.out.println(i) System.out.println System.out System System.out i String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        //String s = sc.next();
        
        
        int k = Integer.parseInt(sc.next());
        int count =0;
        int i=b+1;
        while(count<k){
            i--;
            if((a%i==0)&&(b%i==0)) count++;
        }
        
        System.out.println(i);
    }
}