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): res = x l = 1 while l <= len(fp): tmp = 1 for i in range(l-1): tmp *= fp[i] while tmp * fp[-1] > x: fp.pop() if len(fp) < l: return res for p in permutations(fp,l): tmp = 1 for i in p: tmp *= i if l%2: res -= x//tmp else: res += x//tmp ans = 0 #pの全探索 const = 3 * 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 = 0 # for num in range(lq+1,rq+1): # for i in fp_: # if num%i == 0: # break # else: # cnt += 1 cnt = calc(rq,fp_[:]) - calc(lq,fp_[:]) ans += cnt*res print(ans)