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 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(m//rq, m//lq+1): rq = m // res lq = m // (res + 1) + 1 #加算されるのがlの範囲 lq = max(olq-1,lq) rq = min(rq,orq-1) if lq >= lq: continue #この内倍数でもなければ2の倍数でもないもの fp_ = [2] + fp while fp_ and fp_[-1] > nrq: fp_.pop() cnt = rq - lq l_ = len(fp) for i in range(l_): r = fp_[i] if rq < r: break cnt -= rq//r - lq//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 += rq//(r*s) - lq//(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 -= rq//(r*s*t) - lq//(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 += rq//(r*s*t*u) - lq//(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 -= rq//(r*s*t*u*v) - lq//(r*s*t*u*v) print(ans)