#include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) typedef long long ll; #define MIN(a, b) ((a)>(b)? (b): (a)) #define MAX(a, b) ((a)<(b)? (b): (a)) #define LINF 9223300000000000000 #define INF 2140000000 const long long MOD = 1000000007; using namespace std; vector pp; vector a; void preparePrime( int maxp ) { int i; a.resize(maxp+1); for(i=2; i<=maxp; i++) { int k=i+i; while(k<=maxp) { a[k]=1; k+=i; } } for(i=2; i<=maxp; i++) { if(a[i]==0) pp.push_back( i ); } return; } int main(int argc, char* argv[]) { int n; scanf("%d", &n); preparePrime( n ); int cnt=0; int i, j; double lim=sqrt((double)n)+0.1; for(i=2; i<=lim; i++) { if(a[i]) continue; int k = i*i; for(j=0; j<(int)pp.size(); j++) { int val=k-pp[j]; if(val>n) continue; if(val<2) break; if (a[val]==0) { cnt++; } } } printf("%d\n", cnt); return 0; }