#include using namespace std; typedef long long ll; #define REP(i,n) for(int (i)=0;(i)<(n);++(i)) #define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i)) #define EACH(e,v) for(auto& e:v) #define ALL(v) (v).begin(),(v).end() #define SORT(v) sort(ALL(v)) #define RSORT(v) sort((v).rbegin(),(v).rend()) #define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v))) #define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end()) template inline bool chmax(A &a,const B &b){if(a inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;} const int MOD = (int)1e9 + 7; const int INF = 1 << 30; const ll INFF = 1LL << 62; // 下にy, 右にx enum {R, U, L, D}; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; using vb = vector; /* ・エラトステネスの篩 > O(nloglogn) [使用例] vb prime = Eratosthenes(100000); [備考] nが10^6以下のときに使うべき */ inline vb Eratosthenes(const int n) { vb r(n+1,true); for(int i=2;i*i<=n;++i){ if(r[i]){ for(int j=i*2;j<=n;j+=i)r[j]=false; } } if(r.size()>2){r[0]=0;r[1]=0;} else if(r.size()>1){r[0]=0;} return r; } signed main() { int N; cin >> N; vector prime; auto era = Eratosthenes(N); REP(i, N + 1) if (era[i]) prime.emplace_back(i); ll res = 0; EACH(r, prime) EACH(q, prime) { ll p = (ll)r * r - q; if (p >= 2 && p <= N) { if (era[p]) ++res; } if (p > N) break; } cout << res << endl; // EACH(e,prime)cerr<