#include <bits/stdc++.h>
using namespace std;

int main() {
int K;
  cin >> K;
  int result = 0;
  for(int a = 1;a <= N;a++){
    for(int b = 1;b <= N;b++){
      for(int c = 1;c <= N;c++){
        for(int d = 200;d >= 1;d -= 1){
          if(a%d==0&&b%d==0&&c%d==0){
            result += d;
            break;
          }
        }
      }
    }
  }

cout<<result<<endl;
}