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

#SP0000047. Đếm số nguyên tố không vượt quá N (Eratosthenes Prime Numbers)

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 (Eratosthenes Prime Numbers)

Eratosthenes Prime Numbers

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given an integer NN, determine how many primes are less than or equal to NN. A prime must be greater than 11 and have exactly two positive divisors.

Input

One line containing the integer NN.

Output

Print one integer: the number of primes in [1,N][1,N].

Subtasks

  • Subtask 1 (20 points): 1≤N≤1001\le N\le 100.
  • Subtask 2 (30 points): 1≤N≤100001\le N\le 10000.
  • Subtask 3 (50 points): 1≤N≤10000001\le N\le 1000000.

Examples

Input

11

Output

5

Explanation

The primes not exceeding 1111 are 2,3,5,7,112,3,5,7,11, so the count is 55. The number 9=3⋅39=3\cdot3 is composite and is not counted.