#include #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple; int N; std::vector primes; bool isPrime(int n){ if(n == 1){ return false; }else if(n == 2){ return true; } if(n % 2 == 0){ return false; } for(int i=3;i*i<=n;i+=2){ if(n % i == 0){ return false; } } return true; } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N; if(N >= 2){ primes.emplace_back(2); } for(int i=3;i<=N;i+=2){ if(isPrime(i)){ primes.emplace_back(i); } } int cnt = 0; for(int r : primes){ if(r > 2 * N / r){ break; } for(int p : primes){ int q = r * r - p; if(q > 0 && std::binary_search(primes.begin(), primes.end(), q)){ cnt += 1; } } } std::cout << cnt << std::endl; }