#include #include using namespace std; int n; bool is_prime[300001]; vector primes; void setPrime() { for (int i = 2; i <= 3 * n; i++) is_prime[i] = true; for (int i = 2; i <= 3 * n; i++) { if (is_prime[i]) { for (int j = i * 2; j <= 3 * n; j += i) { is_prime[j] = false; } } } for (int i = 2; i <= n; i++) { if (is_prime[i]) primes.push_back(i); } } int main() { cin >> n; setPrime(); long long ans = 0; for (int i = 0; i < primes.size(); i++) { for (int j = i + 1; j < primes.size(); j++) { for (int k = j + 1; k < primes.size(); k++) { if (is_prime[primes[i] + primes[j] + primes[k]]) { ans++; } } } } cout << ans << endl; return 0; }