#include #define rep(i, n) for(long long i = 0; i < (long long)(n); i++) using namespace std; using ll = long long; class eratosthenes { public: vector prime_n; bool prime[500001]; eratosthenes() { fill(prime, prime + 500001, true); //素数 prime[0] = prime[1] = false; for (int i = 2; i < 500001; i++) { if (prime[i] == true) { prime_n.push_back(i); for (int j = 2; i * j < 500001; j++) { prime[i * j] = false; } } } } }; int main(){ int n; cin >> n; eratosthenes p; vector prime; rep(i, p.prime_n.size()){ if(p.prime_n[i] > n) break; prime.push_back(p.prime_n[i]); } vector sprime; rep(i, prime.size()){ if(prime[i] * prime[i] > n*n) break; sprime.push_back(prime[i] * prime[i]); } set st; rep(i, prime.size()){ if(prime[i] > n) break; st.insert(prime[i]); } int ans = 0; rep(i, prime.size()){ rep(j, sprime.size()){ int tmp = sprime[j] - prime[i]; if(tmp < 0) continue; if(tmp <= n && st.find(tmp) != st.end()) ans++; } } cout << ans << endl; return 0; }