#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int k,min_;
    long long int sum=0, mul=1;
    cin >> k;
    for (int i=1; i<=k; i++){
        for (int j=1; j<=k; j++){
            for (int l=1; l<=k; l++){
                int i1 = i;
                int j1 = j;
                int l1 = l;
                min_ = min(l1,min(i1,j1));
                mul = 1;
                
                for (int m=2; m<=k;){
                    if(min_ % m == 0 && i1 % m == 0 && j1 % m == 0 && l1 % m == 0 ){
                        mul = mul*m;
                        i1 = i1 / m;
                        j1 = j1 / m;
                        l1 = l1 / m;
                        min_ = min(l1,min(i1,j1));
                        //cout << i1 << j1 << l1 << min1;
                    }
                    else m++;
                }
                sum += mul;
                
            }
        }
    }
    
    cout << sum << endl;
    return 0;
}