from fractions import gcd
k = int(input())
gcd_sum=[0]*201
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        gcd_sum[i] += gcd(i,j)
for i in range(1,k+1):
    for j in range(1,k+1):
        g = gcd(i,j)
        ans += gcd_sum[g]
print(ans)