Algorithm


A. Almost Prime
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and n, inclusive.

Input

Input contains one integer number n (1 ≤ n ≤ 3000).

Output

Output the amount of almost prime numbers between 1 and n, inclusive.

Examples
input
Copy
10
output
Copy
2
input
Copy
21
output
Copy
8



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <iostream>
#include  <memory.h>

using namespace std;

int const N = 3001;
bool prime[N];

void sieve() {
    for (int p = 2; p*p  <= N; p++)
        if (prime[p] == false)
            for (int i = p * 2; i  <= N; i += p)
                prime[i] = true;
}

int main() {
    prime[0] = true;
    prime[1] = true;
    sieve();
    
    int n, c = 0, cc = 0;
    cin >> n;
    
    for(int i = 1; i <= n; i++, cc = 0) {
        for(int j = 1; j  <= i; j++)
            if(!prime[j] && i % j == 0) cc++;
        
        if(cc == 2) c++;
    }
    
    cout  < < c  < < endl;
    
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10

Output

x
+
cmd
2
Advertisements

Demonstration


Codeforcess SOlution 26A. Almost Prime C,C++, Java, Js and Python ,26A. Almost Prime,26A,Codeforcess SOlution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+