import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc sc.close() sc.close sc int yono = 0; yono 0 for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        } int a = 1 ; int a = 1 ; a 1 a <= k a k a++ a++ a {
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        } {
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        } for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            } int b = 1 ; int b = 1 ; b 1 b <= k b k b++ b++ b {
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            } {
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            } for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                } int c = 1 ; int c = 1 ; c 1 c <= k c k c++ c++ c {
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                } {
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                } int s = 1; s 1 for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    } int q = 1 ; int q = 1 ; q 1 q <= Math.min(a , Math.min(b , c)) q Math.min(a , Math.min(b , c)) Math.min Math a Math.min(b , c) Math.min Math b c q++ q++ q {
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    } {
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    } if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        } a % q == 0 && b % q == 0 && c % q == 0 a % q == 0 && b % q == 0 && c % q == 0 a % q == 0 a % q a q 0 b % q == 0 b % q b q 0 c % q == 0 c % q c q 0 {
                            s = q;
                        } s = q s q yono += s yono s System.out.println(yono) System.out.println System.out System System.out yono String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        sc.close();
        int yono = 0;
        for(int a = 1 ; a <= k ; a++){
            for(int b = 1 ; b <= k ; b++){
                for(int c = 1 ; c <= k ; c++){
                    int s = 1;
                    for(int q = 1 ; q <= Math.min(a , Math.min(b , c)) ; q++){
                        if(a % q == 0 && b % q == 0 && c % q == 0){
                            s = q;
                        }
                    }
                    yono += s;
                }
            }
        }
        System.out.println(yono);
    }
}