def prime_count(N): """ O(N^{0/75}) で、 pi(N//i) を列挙する。 """ sqN = int(N**.5) sum_lo = [0] * (sqN+1) sum_hi = [0] * (sqN+1) for i in range(1, sqN + 1): sum_lo[i] = i - 1 sum_hi[i] = N // i - 1 for p in range(2, sqN + 1): if sum_lo[p] == sum_lo[p - 1]: continue sp = sum_lo[p - 1] pp = p * p for i in range(1, sqN + 1): n = N // i if n < pp: break x = sum_hi[i * p] if i * p <= sqN else sum_lo[n // p] sum_hi[i] -= x - sp for n in range(sqN, pp - 1, -1): sum_lo[n] -= sum_lo[n // p] - sp return sum_lo, sum_hi def dfs(N, primes): # 値、どの素数まで使ったか stack = [(1,1,0)] while stack: n, phi, nxt_i = stack.pop() yield n, phi, nxt_i for i in range(nxt_i, len(primes)): p = primes[i] if phi * (p-1) * p > N: break phi_p = p - 1 n_p=p while True: if phi * phi_p * p > N: break stack.append((n*n_p, phi * phi_p, i+1)) phi_p *= p n_p*=p def main(N): pi_lo, pi_hi = prime_count(N) sqN = len(pi_lo) - 1 def pi(x): if x <= sqN: return pi_lo[x] return pi_hi[N//x] memo = dict() def isprime(n): if n <= sqN: return pi_lo[n] > pi_lo[n-1] if n == 2: return True if n in memo: return memo[n] if pow(2, n-1, n) != 1: memo[n] = False return False for p in primes: if p*p>n: break if n%p==0: memo[n]=False return False memo[n] = True return True primes = [p for p in range(2, sqN+1) if pi_lo[p] > pi_lo[p-1]] if isprime(sqN+1): primes.append(sqN+1) ans = 1 # N = 1 for n, phi, nxt_i in dfs(N, primes): cnt = 0 # 2 乗以上をかける場合 MAX = N // phi for i in range(nxt_i, len(primes)): p = primes[i] k = 1 phi_p = (p-1) while phi_p * p <= MAX: k += 1 phi_p *= p if k == 1: break cnt += k - 1 # 素数をひとつかける場合。(p-1)phi <= N となる p に関する集計 # p - 1 <= N//phi。 k = pi(N//phi) if isprime(N//phi+1): k += 1 k -= nxt_i cnt += max(k, 0) ans += cnt return ans print(main(int(input())))