public class Euler210 {
    public static void main(String[] args) {
        long r = 1000000000L;
        long a = r / 4;
        long countO = r * r + r / 2;
        long countC = r * (2 * r + 1) / 4;
        // count_b: circle points with parity
        long limit = 2 * a * a - 1;
        int parity = (int) (a & 1);
        long maxU = isqrt(limit);
        if ((maxU & 1) != parity)
            maxU--;
        long firstU = parity;
        long totalB = 0;
        long v = isqrt(limit - firstU * firstU);
        if ((v & 1) != parity) {
            v--;
            if (v < 0)
                v = -1;
        }
        for (long u = firstU; u <= maxU; u += 2) {
            if (v < 0)
                break;
            long u2 = u * u;
            while (u2 + v * v > limit) {
                v -= 2;
                if (v < 0)
                    break;
            }
            if (v < 0)
                break;
            long countV = v + 1;
            long mult = (u == 0) ? 1 : 2;
            totalB += mult * countV;
        }
        long degenerate = r - 1;
        System.out.println(countO + countC + totalB - degenerate);
    }

    static long isqrt(long n) {
        if (n < 0)
            return 0;
        long s = (long) Math.sqrt((double) n);
        while (s * s > n)
            s--;
        while ((s + 1) * (s + 1) <= n)
            s++;
        return s;
    }
}
