import java.util.Scanner;

public class Main{

    public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    }
} import java.util.Scanner; Scanner java.util public class Main{

    public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    }
} Main public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    } eukleides {
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    } if(b % a == 0){
            return a;
        } b % a == 0 b % a b a 0 {
            return a;
        } return a; a int mod = b % a; mod b % a b a return eukleides(mod, a); eukleides(mod, a) eukleides mod a int a a int b b public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    } main {
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int border = scan.nextInt(); border scan.nextInt() scan.nextInt scan int gcd = eukleides(Math.min(a, b), Math.max(a, b)); gcd eukleides(Math.min(a, b), Math.max(a, b)) eukleides Math.min(a, b) Math.min Math a b Math.max(a, b) Math.max Math a b int count = 0; count 0 for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        } int i = gcd; int i = gcd; i gcd i >= 1 i 1 i-- i-- i {
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        } {
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        } if(gcd % i == 0){
                count++;
            } gcd % i == 0 gcd % i gcd i 0 {
                count++;
            } count++ count if(count == border){
                System.out.println(i);
                break;
            } count == border count border {
                System.out.println(i);
                break;
            } System.out.println(i) System.out.println System.out System System.out i break; String[] args args public class Main{

    public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    }
} public class Main{

    public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    }
} Main
import java.util.Scanner;

public class Main{

    public static int eukleides(int a, int b){
        if(b % a == 0){
            return a;
        }
        int mod = b % a;

        return eukleides(mod, a);
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int border = scan.nextInt();
        
        // search
        int gcd = eukleides(Math.min(a, b), Math.max(a, b));
        int count = 0;
        for(int i = gcd; i >= 1; i--){
            if(gcd % i == 0){
                count++;
            }
            if(count == border){
                System.out.println(i);
                break;
            }
        }

    }
}