PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000067. Đếm số nguyên tố không vượt quá n (Prime Count)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm số nguyên tố không vượt quá n (Prime Count)

Prime Count

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integer nn, count the primes in [1,n][1,n], including nn itself if prime. A prime exceeds 11 and has exactly two distinct positive divisors, 11 and itself. In particular, 11 is not prime.

Input

One line contains integer nn.

Output

Print one integer: the number of primes not exceeding nn.

Subtasks

  • Subtask 1 (20 points): 1≤n≤100001\le n\le 10000.
  • Subtask 2 (30 points): 1≤n≤10000001\le n\le 1000000.
  • Subtask 3 (50 points): 1≤n≤1000000001\le n\le 100000000.

Examples

Input

5

Output

3

Explanation

In [1,5][1,5], the primes are 2,3,52,3,5. The number 11 is not prime and 4=2⋅24=2\cdot2 is composite, so the count is 3.