import math def compute_mobius(max_d): mob = [1] * (max_d + 1) is_composite = [False] * (max_d + 1) lpf = [0] * (max_d + 1) # Least Prime Factor for i in range(2, max_d + 1): if not is_composite[i]: lpf[i] = i for j in range(i * i, max_d + 1, i): if not is_composite[j]: is_composite[j] = True lpf[j] = i for d in range(2, max_d + 1): if d == 1: continue x = d factors = {} has_sq = False while x != 1: p = lpf[x] cnt = 0 while x % p == 0: cnt += 1 x = x // p if cnt >= 2: has_sq = True break if p in factors: has_sq = True break factors[p] = 1 if has_sq: mob[d] = 0 else: mob[d] = (-1) ** len(factors) return mob def main(): import sys N = int(sys.stdin.readline().strip()) if N == 0: print(0) return k_max = int(math.isqrt(N)) max_d = math.isqrt(N) mob = compute_mobius(max_d) ans = 0 for k in range(1, k_max + 1): k_sq = k * k R = N // k_sq if R == 0: break next_k = k + 1 next_k_sq = next_k * next_k L = (N // next_k_sq) + 1 if L > R: continue # Compute sum_{d=1}^D mob[d] * (floor(R/(d^2)) - floor( (L-1)/(d^2) )) ) D = int(math.isqrt(R)) sum_c = 0 for d in range(1, D + 1): if mob[d] == 0: continue d_sq = d * d term = mob[d] * ( (R // d_sq) - ( (L - 1) // d_sq ) ) sum_c += term ans += sum_c * (k * k) print(ans) if __name__ == "__main__": main()