import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class Euler372 {

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

    static class BeattyKey {
        int d, p, q;
        long n;

        BeattyKey(int d, int p, int q, long n) {
            this.d = d;
            this.p = p;
            this.q = q;
            this.n = n;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            BeattyKey that = (BeattyKey) o;
            return d == that.d && p == that.p && q == that.q && n == that.n;
        }

        @Override
        public int hashCode() {
            int h = d;
            h = h * 1315423911 + p;
            h = h * 1315423911 + q;
            h = h * 1315423911 + (int) (n ^ (n >>> 32));
            return h;
        }
    }

    static class BeattySumSqrt {
        Map<BeattyKey, BigInteger> memo = new HashMap<>();

        BigInteger sumFloor(int d, long n) {
            return sumFloorImpl(d, n, 0, 1);
        }

        boolean geAsqrtD(long a, int d, long rhs) {
            if (rhs <= 0)
                return true;
            BigInteger left = BigInteger.valueOf(a).multiply(BigInteger.valueOf(a)).multiply(BigInteger.valueOf(d));
            BigInteger right = BigInteger.valueOf(rhs).multiply(BigInteger.valueOf(rhs));
            return left.compareTo(right) >= 0;
        }

        long floorLinearSurd(long a, int d, long b, int c) {
            double guessLd = (a * Math.sqrt(d) + b) / c;
            long g = (long) Math.floor(guessLd);

            while (geAsqrtD(a, d, (g + 1) * c - b))
                g++;
            while (!geAsqrtD(a, d, g * c - b))
                g--;
            return g;
        }

        BigInteger sumFloorImpl(int d, long n, int p, int q) {
            if (n == 0)
                return BigInteger.ZERO;

            int s = (int) Math.sqrt(d);
            if (s * s == d) {
                return BigInteger.valueOf(s).multiply(BigInteger.valueOf(n)).multiply(BigInteger.valueOf(n + 1))
                        .divide(BigInteger.valueOf(2));
            }

            BeattyKey key = new BeattyKey(d, p, q, n);
            if (memo.containsKey(key))
                return memo.get(key);

            int a = (s + p) / q;
            int p1 = a * q - p;
            int q1 = (d - p1 * p1) / q;

            long mSigned = floorLinearSurd(n, d, -n * p1, q);
            long m = mSigned;

            BigInteger tri = BigInteger.valueOf(n).multiply(BigInteger.valueOf(n + 1)).divide(BigInteger.valueOf(2));
            BigInteger result = BigInteger.valueOf(a).multiply(tri)
                    .add(BigInteger.valueOf(n).multiply(BigInteger.valueOf(m)))
                    .subtract(sumFloorImpl(d, m, p1, q1));

            memo.put(key, result);
            return result;
        }
    }

    static BigInteger sumCeilSqrt(BeattySumSqrt beatty, int d, long l, long r) {
        if (l > r)
            return BigInteger.ZERO;

        int s = (int) Math.sqrt(d);
        if (s * s == d) {
            BigInteger cnt = BigInteger.valueOf(r - l + 1);
            return BigInteger.valueOf(s).multiply(BigInteger.valueOf(l + r)).multiply(cnt)
                    .divide(BigInteger.valueOf(2));
        }

        BigInteger floors = beatty.sumFloor(d, r).subtract(beatty.sumFloor(d, l - 1));
        return floors.add(BigInteger.valueOf(r - l + 1));
    }

    static BigInteger countRays(long m, long n) {
        long l = m + 1;
        long kMax = (n * n) / (l * l);

        BeattySumSqrt beatty = new BeattySumSqrt();
        BigInteger total = BigInteger.ZERO;

        for (long k = 1; k <= kMax; k += 2) {
            long u = isqrt((n * n) / k);
            if (u < l)
                continue;

            long v = isqrt(((n + 1) * (n + 1)) / (k + 1));

            long x1 = Math.min(u, v);
            if (x1 >= l) {
                total = total.add(sumCeilSqrt(beatty, (int) (k + 1), l, x1))
                        .subtract(sumCeilSqrt(beatty, (int) k, l, x1));
            }

            long x2 = Math.max(l, v + 1);
            if (u >= x2) {
                total = total.add(BigInteger.valueOf(u - x2 + 1).multiply(BigInteger.valueOf(n + 1)))
                        .subtract(sumCeilSqrt(beatty, (int) k, x2, u));
            }
        }

        return total;
    }

    static String solve() {
        return countRays(2000000L, 1000000000L).toString();
    }

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