from itertools import product
K = int(input())
number = [i for i in range(1, K+1)]
comb = list(product(number, repeat=3))
  
amount = 0
for a, b, c in comb:
    if a <= b <= c:
        if a == b and b == c:
            amount += a
        elif a == b or b == c:
            a_k, c_k = a, c
            count = 1
            for i in range(2, int(a**0.5)+1):
                while a_k % i == 0 and c_k % i == 0:
                    count = count * i
            amount += count * 3
        else:
            a_k, b_k, c_k = a, b, c
            count = 1
            for i in range(2, int(a**0.5)+1):
                while a_k % i == 0 and b_k%i == 0 and c_k % i == 0:
                    count = count * i
            amount += count * 6

print(amount)