#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" vector eratosthenes; void create_eratosthenes(int n) { eratosthenes.resize(n + 1, true); eratosthenes[0] = eratosthenes[1] = false; for(int i = 2; (i * i) <= n; i++) { if (!eratosthenes[i]) { continue; } for (int ii = 2; (i * ii) <= n; ii++) { eratosthenes[i * ii] = false; } } } bool is_prime(int n) { return eratosthenes[n]; } int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n; cin >> n; create_eratosthenes(1e6); set prime, exp; reps(i, 1, 1e6 + 1) { if (!is_prime(i)) continue; if (i <= n) prime.insert(i); if ((i * i) <= (2 * n)) exp.insert(i); } ll ans = 0; for(auto r : exp) { for(auto p : prime) { ll q = r * r - p; if (prime.count(q) > 0) { ans++; } } } cout << ans << endl; return 0; }