#include using namespace std; #define rep(i,n) for(ll i=0;i<(n);++i) using ll = long long; using pll = pair; constexpr ll INF = (1LL<<60); constexpr ll MOD = (1e9+7); //constexpr ll MOD = (998244353); template bool chmax(T &a,const T &b){if(a bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;} void dump(){cout< void dump(T&& h, Ts&&... t){cout<(t)...);} template istream &operator>>(istream&is,vector&v){for(auto &elemnt:v)is>>elemnt;return is;} template istream &operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} templatevector make_vector(size_t a){return vector(a);} templateauto make_vector(size_t a, Ts... ts){return vector(ts...))>(a, make_vector(ts...));} void solve1();void solve2(); int main(){ solve1(); return 0; } void solve1(){ ll n; cin>>n; auto prime_enumration = [](ll n){ vector a(n+1,true); for(ll p=2;p<=n;++p){ if(!a[p])continue; ll x=p+p; while(x<=n){a[x]=false;x+=p;} } vector primes; for(ll p=2;p<=n;++p){ if(a[p])primes.emplace_back(p); } sort(primes.begin(),primes.end()); return primes; }; auto square_enum = [](vectorconst& a,ll n,ll limit){ set suq; for(auto const& v:a){ if(v*v>limit)break; suq.insert(v*v); } return suq; }; auto a = prime_enumration(n); ll m = a.size(); ll limit = a[m-1]+a[m-2]; auto b = square_enum(a,n,limit); ll ans = 0; for(auto rr:b){ for(ll p=0;p<=rr;++p){ ll q=rr-p; if(*lower_bound(a.begin(),a.end(),p)!=p)continue; if(*lower_bound(a.begin(),a.end(),q)!=q)continue; ans++; } } cout<<(ans)<