
import java.util.Scanner;

public class Main {

    static int[] prime = {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    static int[] prime = {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    }
} Main static int[] prime = {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97}; prime {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97} 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc long ans = 0; ans 0 for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        } int a=0; int a=0; a 0 a<k a k a++ a++ a {
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        } {
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        } for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            } int b=0; int b=0; b 0 b<k b k b++ b++ b {
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            } {
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            } for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                } int c=0; int c=0; c 0 c<k c k c++ c++ c {
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                } {
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                } if(a == b && a == c){
                        ans += a+1;
                        continue;
                    } a == b && a == c a == b a b a == c a c {
                        ans += a+1;
                        continue;
                    } ans += a+1 ans a+1 a 1 continue; int A = a+1 A a+1 a 1 B = b+1 B b+1 b 1 C = c+1 C c+1 c 1 gcd = 1; gcd 1 for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    } int x=0,y=prime.length; int x=0 x 0 y=prime.length; y prime.length prime prime.length x<y x y x++ x++ x {
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    } {
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    } if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        } A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0 A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0 A%prime[x] != 0 A%prime[x] A prime[x] prime x 0 B%prime[x] != 0 B%prime[x] B prime[x] prime x 0 C%prime[x] != 0 C%prime[x] C prime[x] prime x 0 {  //割り切れないなら次の素数へ
                            continue;
                        } continue; {
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        } gcd *= prime[x] gcd prime[x] prime x A /= prime[x] A prime[x] prime x B /= prime[x] B prime[x] prime x C /= prime[x] C prime[x] prime x x-- x ans += gcd ans gcd System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    static int[] prime = {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    }
} public class Main {

    static int[] prime = {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    }
} Main

import java.util.Scanner;

public class Main {

    static int[] prime = {2,3,5,7,11,13,
            17,19,23,29,31,
            37,41,43,47,53,
            59,61,67,71,73,
            79,83,89,97};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long ans = 0;
        for(int a=0;a<k;a++){
            for(int b=0;b<k;b++){
                for(int c=0;c<k;c++){
                    if(a == b && a == c){
                        ans += a+1;
                        continue;
                    }
                    int A = a+1, B = b+1, C = c+1, gcd = 1;
                    for(int x=0,y=prime.length;x<y;x++){
                        if(A%prime[x] != 0 || B%prime[x] != 0 || C%prime[x] != 0){  //割り切れないなら次の素数へ
                            continue;
                        }else{
                            gcd *= prime[x];
                            A /= prime[x];
                            B /= prime[x];
                            C /= prime[x];
                            x--;    //同じ素数でもう一度試す
                        }
                    }
                    ans += gcd;
                }
            }
        }
        System.out.println(ans);
    }
}
