from math import isqrt n = int(input()) rootn = isqrt(n) minp = [0]*(rootn+1) # 素因数の前計算 for i in range(3,rootn+1,2): if minp[i] != 0: continue for j in range(i,rootn+1,i): if minp[j] == 0: minp[j] = i from itertools import permutations def calc(x,fp): cnt = x l = len(fp) for i in range(l): r = fp[i] if rq < r: break cnt -= x//r for i in range(l): r = fp[i] if rq < r: break for j in range(i+1,l): s = fp[j] if rq < r*s: break cnt += x//(r*s) for i in range(l): r = fp[i] if rq < r: break for j in range(i+1,l): s = fp[j] if rq < r*s: break for k in range(j+1,l): t = fp[k] if rq < r*s*t: break cnt -= x//(r*s*t) for i in range(l): r = fp[i] if rq < r: break for j in range(i+1,l): s = fp[j] if rq < r*s: break for k in range(j+1,l): t = fp[k] if rq < r*s*t: break for g in range(k+1,l): u = fp[g] if rq < r*s*t*u: break cnt += x//(r*s*t*u) for i in range(l): r = fp[i] if rq < r: break for j in range(i+1,l): s = fp[j] if rq < r*s: break for k in range(j+1,l): t = fp[k] if rq < r*s*t: break for g in range(k+1,l): u = fp[g] if rq < r*s*t*u: break for h in range(g+1,l): v = fp[h] if rq < r*s*t*u*v: break cnt -= x//(r*s*t*u*v) return cnt ans = 0 #pの全探索 const = 10**4 for p in range(2,rootn + 1): fp = [] p_ = p while minp[p_] != 0: mp = minp[p_] fp.append(mp) while p_%mp == 0: p_ //= mp # q は奇数 # p < q < 2p # maxの値はm以下 m = n//(2*p) lim = isqrt(m) #ここを境界とします lq = 2 * ((p+1)//2) + 1 rq = min(m+1,2*p) if rq - lq <= const: for r in range(lq,rq,2): if not (0 < r - p < p): continue for i in fp: if r%i == 0: break else: ans += m//r #この倍数まで大丈夫 else: #この時あきらかに const <= lq olq,orq = lq,rq for res in range(max(m//orq,1), m//olq+1): lq = m // (res + 1) rq = m // res #加算されるのがlの範囲 lq = max(lq,olq-1) rq = min(rq,orq-1) if lq >= rq: continue # print(res,p,lq,rq) #この内倍数でもなければ2の倍数でもないもの fp_ = [2] + fp while fp_ and fp_[-1] > rq: fp_.pop() assert fp_.count(2) <= 1 cnt = calc(rq,fp_[:]) - calc(lq,fp_[:]) ans += cnt*res print(ans)