#C5087. Counting Prime Numbers

    ID: 48697 Type: Default 1000ms 256MiB

Counting Prime Numbers

Counting Prime Numbers

Given an integer (n), count the number of prime numbers less than or equal to (n). A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, there are 4 prime numbers (2, 3, 5, 7) less than or equal to 10. You are required to write a program that reads a single integer from standard input and prints the count of prime numbers using an efficient method such as the Sieve of Eratosthenes. The valid range for (n) is (1 \leq n \leq 10^6).

inputFormat

The input consists of a single integer (n) provided via standard input. This integer represents the upper bound (inclusive) for counting prime numbers.

outputFormat

Output a single integer representing the number of prime numbers less than or equal to (n), printed to standard output.## sample

10
4