// yukicoder: No.843 Triple Primes // 2019.6.29 bal4u #include #include #define MAX 1000000 #define SQRT 1000 char nop[MAX+5] = { 1,1,0,0,1 }; // zero: if prime void sieve() { int i, j; for (i = 3; i <= SQRT; i += 2) if (!nop[i]) { for (j = i * i; j <= MAX; j += i) nop[j] = 1; } } int main() { int i, b, N, ans; sieve(); scanf("%d", &N); if (N < 4) ans = 0; else { ans = 0, b = (int)sqrt((double)(N << 1)); for (i = 3; i <= b; i+=2) if (!nop[i] && !nop[i*i-2] && i*i-2 <= N) ans++; ans <<= 1, ans++; } printf("%d\n", ans); return 0; }