#include #include using namespace std; struct SieveEratos{ vector t; SieveEratos(int n):t(n+1,true){ t[0] = t[1] = false; for(int i = 2; n >= i; i++){ if(t[i]){ for(int j = i+i; n >= j; j+=i){ t[j] = false; } } } } bool operator[](int x){return t[x];} }; int main(){ int n;cin>>n; SieveEratos A(n); int ans = 0; for(int i = 0; n >= i*i; i++){ if(!A[i])continue; for(int j = 0; (i*i)/2 >= j; j++){ if(A[j] && A[(i*i)-j]){ ans++; if(j+j != i*i)ans++; } } } cout << ans << endl; }