import java.math.BigInteger;
import java.util.*;

public class Euler621 {
    static final BigInteger TWO = BigInteger.valueOf(2);
    static final BigInteger THREE = BigInteger.valueOf(3);

    static boolean isPrime(long n) {
        if (n < 2)
            return false;
        long[] bases = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 };
        for (long p : bases) {
            if (n % p == 0)
                return n == p;
        }
        BigInteger bn = BigInteger.valueOf(n);
        return bn.isProbablePrime(10);
    }

    static long pollardRho(long n) {
        if ((n & 1) == 0)
            return 2;
        BigInteger bn = BigInteger.valueOf(n);
        Random rng = new Random();
        BigInteger c = new BigInteger(bn.bitLength(), rng).mod(bn);
        BigInteger x = new BigInteger(bn.bitLength(), rng).mod(bn);
        BigInteger y = x;
        BigInteger d = BigInteger.ONE;
        while (d.equals(BigInteger.ONE)) {
            x = x.multiply(x).add(c).mod(bn);
            y = y.multiply(y).add(c).mod(bn);
            y = y.multiply(y).add(c).mod(bn);
            d = x.subtract(y).abs().gcd(bn);
        }
        if (!d.equals(bn))
            return d.longValue();
        return pollardRho(n);
    }

    static void factorRec(long n, Map<Long, Integer> out) {
        if (n == 1)
            return;
        if (isPrime(n)) {
            out.put(n, out.getOrDefault(n, 0) + 1);
            return;
        }
        long d = pollardRho(n);
        factorRec(d, out);
        factorRec(n / d, out);
    }

    static BigInteger tonelliShanks(BigInteger n, BigInteger p) {
        if (n.equals(BigInteger.ZERO))
            return BigInteger.ZERO;
        if (p.equals(TWO))
            return n;
        if (!n.modPow(p.subtract(BigInteger.ONE).divide(TWO), p).equals(BigInteger.ONE))
            return BigInteger.ZERO;
        if (p.mod(BigInteger.valueOf(4)).equals(THREE)) {
            return n.modPow(p.add(BigInteger.ONE).divide(BigInteger.valueOf(4)), p);
        }
        BigInteger q = p.subtract(BigInteger.ONE);
        int s = 0;
        while (q.mod(TWO).equals(BigInteger.ZERO)) {
            q = q.divide(TWO);
            s++;
        }
        BigInteger z = TWO;
        while (!z.modPow(p.subtract(BigInteger.ONE).divide(TWO), p).equals(p.subtract(BigInteger.ONE))) {
            z = z.add(BigInteger.ONE);
        }
        BigInteger c = z.modPow(q, p);
        BigInteger r = n.modPow(q.add(BigInteger.ONE).divide(TWO), p);
        BigInteger t = n.modPow(q, p);
        int m = s;

        while (!t.equals(BigInteger.ONE)) {
            int i = 1;
            BigInteger tt = t.multiply(t).mod(p);
            while (i < m && !tt.equals(BigInteger.ONE)) {
                tt = tt.multiply(tt).mod(p);
                i++;
            }
            BigInteger b = c.modPow(TWO.pow(m - i - 1), p);
            r = r.multiply(b).mod(p);
            BigInteger b2 = b.multiply(b).mod(p);
            t = t.multiply(b2).mod(p);
            c = b2;
            m = i;
        }
        return r;
    }

    static ArrayList<Long> rootsModPrimePower(long D, long p, int e) {
        BigInteger bp = BigInteger.valueOf(p);
        BigInteger pe = bp.pow(e);
        BigInteger bD = BigInteger.valueOf(D);
        BigInteger Dmod = bD.mod(bp);
        if (Dmod.signum() < 0)
            Dmod = Dmod.add(bp);

        ArrayList<Long> res = new ArrayList<>();
        if (Dmod.equals(BigInteger.ZERO)) {
            if (e == 1) {
                res.add(0L);
                return res;
            }
            return res;
        }

        BigInteger r = tonelliShanks(Dmod, bp);
        if (r.equals(BigInteger.ZERO))
            return res;

        BigInteger pk = bp;
        for (int k = 1; k < e; k++) {
            BigInteger pk1 = pk.multiply(bp);
            BigInteger Dmod_k1 = bD.mod(pk1);
            if (Dmod_k1.signum() < 0)
                Dmod_k1 = Dmod_k1.add(pk1);
            BigInteger r2 = r.multiply(r).mod(pk1);
            BigInteger diff = Dmod_k1.subtract(r2).mod(pk1);
            if (diff.signum() < 0)
                diff = diff.add(pk1);
            BigInteger delta = diff.divide(pk);
            BigInteger inv = r.multiply(TWO).modInverse(bp);
            BigInteger t = delta.multiply(inv).mod(bp);
            r = r.add(t.multiply(pk));
            pk = pk1;
        }
        r = r.mod(pe);
        BigInteger r2 = pe.subtract(r).mod(pe);
        res.add(r.longValue());
        if (!r2.equals(r))
            res.add(r2.longValue());
        return res;
    }

    static int[] sieveSpf(int n) {
        int[] spf = new int[n + 1];
        ArrayList<Integer> primes = new ArrayList<>();
        for (int i = 2; i <= n; i++) {
            if (spf[i] == 0) {
                spf[i] = i;
                primes.add(i);
            }
            for (int p : primes) {
                if ((long) p * i > n)
                    break;
                spf[p * i] = p;
                if (p == spf[i])
                    break;
            }
        }
        return spf;
    }

    static ArrayList<int[]> factorizeSmall(int x, int[] spf) {
        ArrayList<int[]> f = new ArrayList<>();
        while (x > 1) {
            int p = spf[x];
            int e = 0;
            while (x % p == 0) {
                x /= p;
                e++;
            }
            f.add(new int[] { p, e });
        }
        return f;
    }

    static long classNumberOddFundamental(long D) {
        long absD = -D;
        long maxA = (long) Math.sqrt(absD / 3.0);
        while (3 * (maxA + 1) * (maxA + 1) <= absD)
            maxA++;
        while (3 * maxA * maxA > absD)
            maxA--;

        int lim = (int) maxA;
        int[] spf = sieveSpf(lim);
        long h = 0;

        for (int a = 1; a <= lim; a += 2) {
            ArrayList<int[]> fac = factorizeSmall(a, spf);
            BigInteger mod = BigInteger.ONE;
            ArrayList<Long> roots = new ArrayList<>();
            roots.add(0L);
            boolean ok = true;

            for (int[] pe_arr : fac) {
                long p = pe_arr[0];
                int e = pe_arr[1];
                BigInteger pe = BigInteger.valueOf(p).pow(e);
                ArrayList<Long> rpe = rootsModPrimePower(D, p, e);
                if (rpe.isEmpty()) {
                    ok = false;
                    break;
                }
                BigInteger inv = mod.mod(pe).modInverse(pe);
                ArrayList<Long> nxt = new ArrayList<>();
                for (long x : roots) {
                    BigInteger bx = BigInteger.valueOf(x);
                    BigInteger xpe = bx.mod(pe);
                    for (long y : rpe) {
                        BigInteger t = BigInteger.valueOf(y).subtract(xpe).mod(pe);
                        if (t.signum() < 0)
                            t = t.add(pe);
                        t = t.multiply(inv).mod(pe);
                        nxt.add(bx.add(mod.multiply(t)).longValue());
                    }
                }
                mod = mod.multiply(pe);
                roots = nxt;
            }
            if (!ok)
                continue;

            for (long r : roots) {
                long bmod = r;
                if (bmod % 2 == 0)
                    bmod += a;
                bmod %= (2L * a);
                long b = bmod;
                if (b > a)
                    b -= 2L * a;
                if (b == -a)
                    b = a;

                BigInteger bb = BigInteger.valueOf(b);
                BigInteger num = bb.multiply(bb).subtract(BigInteger.valueOf(D));
                long den = 4L * a;
                if (!num.mod(BigInteger.valueOf(den)).equals(BigInteger.ZERO))
                    continue;
                long c = num.divide(BigInteger.valueOf(den)).longValue();
                if (a > c)
                    continue;
                if ((a == c || Math.abs(b) == a) && b < 0)
                    continue;
                h++;
            }
        }
        return h;
    }

    static int jacobiSymbol(long a, long n) {
        a %= n;
        if (a < 0)
            a += n;
        int s = 1;
        while (a != 0) {
            while (a % 2 == 0) {
                a /= 2;
                long r = n % 8;
                if (r == 3 || r == 5)
                    s = -s;
            }
            long temp = a;
            a = n;
            n = temp;
            if (a % 4 == 3 && n % 4 == 3)
                s = -s;
            a %= n;
        }
        return n == 1 ? s : 0;
    }

    static int kroneckerDOver2(long D) {
        long r = D % 8;
        if (r < 0)
            r += 8;
        if (r == 1 || r == 7)
            return 1;
        if (r == 3 || r == 5)
            return -1;
        return 0;
    }

    static BigInteger sigmaPrimePower(long p, int e) {
        BigInteger bp = BigInteger.valueOf(p);
        BigInteger pe1 = bp.pow(e + 1);
        return pe1.subtract(BigInteger.ONE).divide(bp.subtract(BigInteger.ONE));
    }

    static long r3SumOfThreeSquares(long N) {
        Map<Long, Integer> pf = new HashMap<>();
        factorRec(N, pf);
        long m = 1;
        ArrayList<Long> primes = new ArrayList<>();
        ArrayList<Integer> exps = new ArrayList<>();
        for (Map.Entry<Long, Integer> entry : pf.entrySet()) {
            long p = entry.getKey();
            int e = entry.getValue();
            if (e % 2 == 1)
                m *= p;
            int k = e / 2;
            if (k > 0) {
                primes.add(p);
                exps.add(k);
            }
        }

        long D = -m;
        long h = classNumberOddFundamental(D);
        int w = (D == -3) ? 6 : ((D == -4) ? 4 : 2);
        int oneMinus = 1 - kroneckerDOver2(D);

        int kLen = primes.size();
        BigInteger S = BigInteger.ZERO;

        for (int mask = 0; mask < (1 << kLen); mask++) {
            long d = 1;
            int mu = 1;
            BigInteger sigma = BigInteger.ONE;
            for (int i = 0; i < kLen; i++) {
                int e = exps.get(i);
                if ((mask & (1 << i)) != 0) {
                    d *= primes.get(i);
                    mu = -mu;
                    e--;
                }
                sigma = sigma.multiply(sigmaPrimePower(primes.get(i), e));
            }
            int chi = jacobiSymbol(D, d);
            if (chi == 0)
                continue;
            S = S.add(sigma.multiply(BigInteger.valueOf(mu)).multiply(BigInteger.valueOf(chi)));
        }

        BigInteger t = S.multiply(BigInteger.valueOf(12L * (2 * h) * oneMinus));
        return t.divide(BigInteger.valueOf(w)).longValue();
    }

    public static String solve() {
        long n = 17526L * 1000000000L;
        long N = 8 * n + 3;
        long r3 = r3SumOfThreeSquares(N);
        return Long.toString(r3 / 8);
    }

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