// yukicoder: No.152 貯金箱の消失 // 2019.7.21 bal4u #include #include int gcd(int a, int b) { int r; while (b != 0) r = a % b, a = b, b = r; return a; } #define MAX 1120 // =sqrt(10^7/8) #define SQRT 33 // =sqrt(MAX) char notPrime[MAX+2] = { 1,1,0,0,1 }; // zero: if prime void sieve() { int i, j; for (i = 3; i <= SQRT; i += 2) if (!notPrime[i]) { for (j = i * i; j <= MAX; j += i) notPrime[j] = 1; } } int main() { int i, m, mm, n, nn, L, ans = 0; sieve(); scanf("%d", &L), L >>= 3; mm = (int)sqrt((double)L); for (m = 2; m <= mm; m += 2) { nn = L/m-m; if (nn >= m) nn = m-1; for (n = 1; n <= nn; n += 2) if (gcd(m, n) == 1) ans++; } for (m = 3; m <= mm; m += 2) { nn = L/m-m; if (nn >= m) nn = m-1; if (!notPrime[m]) ans += nn >> 1; else for (n = 2; n <= nn; n += 2) if (gcd(m, n) == 1) ans++; } printf("%d\n", ans); return 0; }