#include <stdio.h>
#include <math.h>

int main(void)
{
  long int i, j, k, l, n, result, sum = 0;
  
  scanf("%ld", &n);
  
  for( i = 1; i < n+1; i++ ){
    for( j = 1; j < n+1; j++ ){
      for( k = 1; k < n+1; k++ ){
        result = 0;
        for( l = 1; l < 3; l++ ){       	 
     	   if( i % l == 0 && j % l == 0 && k % l == 0 ){
          	result = l;
           }
        }
        sum += result;
      }
    }
  }
 
  printf("%ld\n", sum);
  return 0;
}