import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

public class Euler246 {

    static long isqrtU128(BigInteger x) {
        if (x.compareTo(BigInteger.ZERO) <= 0)
            return 0;
        // BigInteger has sqrt() in newer Java, but let's just use double as an initial
        // guess, then refine.
        long r = (long) Math.sqrt(x.doubleValue());

        while (BigInteger.valueOf(r + 1).multiply(BigInteger.valueOf(r + 1)).compareTo(x) <= 0) {
            r++;
        }
        while (BigInteger.valueOf(r).multiply(BigInteger.valueOf(r)).compareTo(x) > 0) {
            r--;
        }
        return r;
    }

    static class EllipseData {
        long a2, b2;
        long r2Circle;
        BigInteger ab2;

        EllipseData(long a2, long b2) {
            this.a2 = a2;
            this.b2 = b2;
            this.r2Circle = a2 + b2;
            this.ab2 = BigInteger.valueOf(a2).multiply(BigInteger.valueOf(b2));
        }
    }

    static long minYOutside(long x, EllipseData e) {
        BigInteger lhs = BigInteger.valueOf(e.b2).multiply(BigInteger.valueOf(x)).multiply(BigInteger.valueOf(x));
        BigInteger rhs = e.ab2;
        if (lhs.compareTo(rhs) > 0)
            return 0;
        if (lhs.equals(rhs))
            return 1;

        BigInteger rem = rhs.subtract(lhs);
        BigInteger q = rem.divide(BigInteger.valueOf(e.a2));
        long y = isqrtU128(q);

        while (BigInteger.valueOf(e.a2).multiply(BigInteger.valueOf(y)).multiply(BigInteger.valueOf(y))
                .compareTo(rem) <= 0) {
            y++;
        }
        return y;
    }

    static BigInteger angleIneq(long x, BigInteger u, EllipseData e) {
        BigInteger x2 = BigInteger.valueOf(x).multiply(BigInteger.valueOf(x));

        BigInteger term1Inner = BigInteger.valueOf(e.b2).multiply(x2)
                .add(BigInteger.valueOf(e.a2).multiply(u))
                .subtract(e.ab2);

        BigInteger term1 = term1Inner.multiply(BigInteger.valueOf(4));

        BigInteger t = BigInteger.valueOf(e.a2).add(BigInteger.valueOf(e.b2))
                .subtract(x2).subtract(u);

        return term1.subtract(t.multiply(t));
    }

    static long maxYOutside(long x, EllipseData e) {
        BigInteger x2 = BigInteger.valueOf(x).multiply(BigInteger.valueOf(x));

        BigInteger k = BigInteger.valueOf(e.a2).add(BigInteger.valueOf(e.b2)).subtract(x2);
        BigInteger b = BigInteger.valueOf(4 * e.a2).add(k.multiply(BigInteger.valueOf(2)));

        BigInteger cInner = BigInteger.valueOf(e.b2).multiply(x2).subtract(e.ab2);
        BigInteger c = cInner.multiply(BigInteger.valueOf(4)).subtract(k.multiply(k));

        BigInteger d = b.multiply(b).add(c.multiply(BigInteger.valueOf(4)));

        if (d.compareTo(BigInteger.ZERO) <= 0)
            return -1;

        long sqrtD = isqrtU128(d);
        BigInteger uMax = b.add(BigInteger.valueOf(sqrtD)).divide(BigInteger.valueOf(2));

        if (uMax.compareTo(BigInteger.ZERO) < 0)
            return -1;

        while (uMax.compareTo(BigInteger.ZERO) >= 0 && angleIneq(x, uMax, e).compareTo(BigInteger.ZERO) <= 0) {
            uMax = uMax.subtract(BigInteger.ONE);
        }

        if (uMax.compareTo(BigInteger.ZERO) < 0)
            return -1;

        long y = isqrtU128(uMax);
        while (y >= 0 && angleIneq(x, BigInteger.valueOf(y).multiply(BigInteger.valueOf(y)), e)
                .compareTo(BigInteger.ZERO) <= 0) {
            y--;
        }

        return y;
    }

    static boolean qualifies(long x, long y, EllipseData e) {
        BigInteger x2 = BigInteger.valueOf(x).multiply(BigInteger.valueOf(x));
        BigInteger y2 = BigInteger.valueOf(y).multiply(BigInteger.valueOf(y));

        BigInteger lhs = BigInteger.valueOf(e.b2).multiply(x2).add(BigInteger.valueOf(e.a2).multiply(y2));
        if (lhs.compareTo(e.ab2) <= 0)
            return false;

        BigInteger r2 = x2.add(y2);
        if (r2.compareTo(BigInteger.valueOf(e.r2Circle)) <= 0)
            return true;

        return angleIneq(x, y2, e).compareTo(BigInteger.ZERO) > 0;
    }

    public static String solve() {
        long kMx = -2000;
        long kGx = 8000;
        long kRadius = 15000;

        long d = Math.abs(kGx - kMx);
        long a = kRadius / 2;
        long c = d / 2;
        long a2 = a * a;
        long b2 = a2 - c * c;

        EllipseData e = new EllipseData(a2, b2);

        long xLimit = isqrtU128(BigInteger.valueOf(e.a2).add(BigInteger.valueOf(6 * e.b2))) + 2;
        long yLimit = isqrtU128(BigInteger.valueOf(e.b2).add(BigInteger.valueOf(6 * e.a2))) + 2;

        int threads = Math.max(1, Runtime.getRuntime().availableProcessors());
        long totalX = xLimit + 1;
        long chunk = (totalX + threads - 1) / threads;

        ExecutorService executor = Executors.newFixedThreadPool(threads);
        List<Future<Long>> futures = new ArrayList<>();

        for (int t = 0; t < threads; ++t) {
            final long start = t * chunk;
            final long end = Math.min(start + chunk, totalX);
            if (start >= end)
                break;

            futures.add(executor.submit(() -> {
                long local = 0;
                for (long x = start; x < end; ++x) {
                    long yMin = minYOutside(x, e);
                    long yCircle = -1;
                    long x2 = x * x;
                    if (x2 <= e.r2Circle) {
                        yCircle = isqrtU128(BigInteger.valueOf(e.r2Circle).subtract(BigInteger.valueOf(x2)));
                    }
                    if (yCircle >= yMin) {
                        local += yCircle - yMin + 1;
                    }

                    long yStart = Math.max(yMin, yCircle + 1);
                    long yMax = maxYOutside(x, e);
                    if (yMax >= yStart) {
                        local += yMax - yStart + 1;
                    }
                }
                return local;
            }));
        }

        long countQ1 = 0;
        for (Future<Long> f : futures) {
            try {
                countQ1 += f.get();
            } catch (Exception ex) {
            }
        }
        executor.shutdown();

        long countXAxis = 0;
        for (long x = 0; x <= xLimit; ++x) {
            if (qualifies(x, 0, e))
                countXAxis++;
        }

        long countYAxis = 0;
        for (long y = 0; y <= yLimit; ++y) {
            if (qualifies(0, y, e))
                countYAxis++;
        }

        long origin = qualifies(0, 0, e) ? 1 : 0;

        long ans = 4 * countQ1 - 2 * countXAxis - 2 * countYAxis + origin;
        return String.valueOf(ans);
    }

    public static void main(String[] args) {
        System.out.println(solve());
    }
}
