#include<stdio.h>
int max(int a,int b,int c);
int main(){
    int k;
    scanf("%d",&k);
    int ans = 0;
    for(int a=1;a<=k;a+=2){
        for(int b=1;b<=k;b+=2){
            for(int c=1;c<=k;c+=2){
                for(int i=max(a,b,c);i>0;i--){
                    if(a % i == 0 && b % i == 0 && c % i == 0)ans += i;
                    if((a+1) <= k && (a+1) % i == 0 && (b+1) % i == 0 && (c+1) % i == 0)ans += i;
                }
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}
int max(int a, int b, int c){
    if(a > b){
        if(a > c)return a;
        else return c;
    }
    else if (b > c)return b;
    else return c;
}