#include <stdio.h>

int main (void)
{
 int i,j,k;
int n;
int m;
int count = 0;
scanf("%d",&n);

for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
for(k=1;k;<=n;k++)
{m=n;
do
{
if(i%m==0&&j%m==0&&k%m==0)
count += m;
m--;
}
}
}while(i%m!=0&&j%m!=0&&k%m!=0)

printf("%d",count);

return 0;
}
