#include <bits/stdc++.h>
using namespace std;
int main (){
  int i,a,b,c,j,k,l,f=1,t=0,m;
  cin>>m;
  a=m;b=m;c=m;
  for(i=1;i<=a;i++){
    for(j=1;j<=b;j++){
      for(k=1;k<=c;k++){
        l=min(i,min(j,k));
        while(f==1){
          if(i%l==0&&j%l==0&&k%l==0){
            f++;
            
            t=l+t;
            //cout<<i<<j<<k<<t<<l<<endl;
          }
          l--;
        }
        f=1;
      }
    }
  }
  cout<<t<<endl;
  return 0;
}