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

public class Euler251 {
    static final long LIMIT = 110000000L;

    static List<Integer> sievePrimes(int limit) {
        boolean[] isPrime = new boolean[limit + 1];
        for (int i = 2; i <= limit; i++)
            isPrime[i] = true;

        for (int i = 2; (long) i * i <= limit; ++i) {
            if (!isPrime[i])
                continue;
            for (int j = i * i; j <= limit; j += i) {
                isPrime[j] = false;
            }
        }

        List<Integer> primes = new ArrayList<>();
        for (int i = 2; i <= limit; ++i) {
            if (isPrime[i])
                primes.add(i);
        }
        return primes;
    }

    static int[] buildSPF(int n) {
        int[] spf = new int[n + 1];
        if (n >= 1)
            spf[1] = 1;
        List<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) {
                long v = (long) p * i;
                if (v > n || p > spf[i])
                    break;
                spf[(int) v] = p;
            }
        }
        return spf;
    }

    static class Factor {
        int p, e;

        Factor(int p, int e) {
            this.p = p;
            this.e = e;
        }
    }

    static void factorizeWithSPF(int x, int[] spf, List<Factor> factors) {
        factors.clear();
        while (x > 1) {
            int p = spf[x];
            int e = 0;
            do {
                x /= p;
                e++;
            } while (x > 1 && spf[x] == p);
            factors.add(new Factor(p, e));
        }
    }

    static void factorizeSquarePart(long m, List<Integer> primes, List<Factor> squareFactors) {
        squareFactors.clear();
        long x = m;
        for (int p : primes) {
            if ((long) p * p > x)
                break;
            if (x % p != 0)
                continue;
            int e = 0;
            do {
                x /= p;
                e++;
            } while (x % p == 0);
            if (e >= 2) {
                squareFactors.add(new Factor(p, e / 2));
            }
        }
    }

    static void generateDivisors(List<Factor> factors, List<Long> divisors) {
        divisors.clear();
        divisors.add(1L);
        for (Factor f : factors) {
            int baseSize = divisors.size();
            long pe = 1;
            for (int k = 1; k <= f.e; ++k) {
                pe *= f.p;
                for (int i = 0; i < baseSize; ++i) {
                    divisors.add(divisors.get(i) * pe);
                }
            }
        }
    }

    static long floorSqrt(long x) {
        if (x <= 0)
            return 0;
        long r = (long) Math.sqrt(x);
        while (BigIntegerUtil.multiply(r + 1, r + 1).compareTo(BigIntegerUtil.valueOf(x)) <= 0)
            r++;
        while (BigIntegerUtil.multiply(r, r).compareTo(BigIntegerUtil.valueOf(x)) > 0)
            r--;
        return r;
    }

    static boolean canHaveSolution(long u, long limit) {
        double uu = (double) u;
        double mm = 8.0 * uu - 3.0;
        double lowerBound = 3.0 * uu - 1.0 + 3.0 * Math.cbrt((uu * uu * mm) / 4.0);
        return lowerBound <= (double) limit + 1e-9;
    }

    static long maxUBound(long limit) {
        long lo = 0;
        long hi = (limit + 1) / 3;
        while (lo < hi) {
            long mid = lo + (hi - lo + 1) / 2;
            if (canHaveSolution(mid, limit)) {
                lo = mid;
            } else {
                hi = mid - 1;
            }
        }
        return lo;
    }

    static long gcd(long a, long b) {
        while (b != 0) {
            long t = b;
            b = a % b;
            a = t;
        }
        return a;
    }

    public static String solve() {
        if (LIMIT < 8)
            return "0";

        long maxU = maxUBound(LIMIT);
        if (maxU <= 0)
            return "0";

        int sqrtMaxM = (int) Math.sqrt(8.0 * maxU - 3.0) + 1;
        List<Integer> primes = sievePrimes(sqrtMaxM);
        int[] spf = buildSPF((int) maxU);

        int threads = Math.max(1, Runtime.getRuntime().availableProcessors());
        threads = (int) Math.min(threads, Math.max(1, maxU));

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

        for (int t = 0; t < threads; ++t) {
            final int tId = t;
            final int tCount = threads;
            futures.add(executor.submit(() -> {
                List<Factor> factorsU = new ArrayList<>(16);
                List<Factor> squareFactorsM = new ArrayList<>(8);
                List<Long> divisorsH = new ArrayList<>(256);
                List<Long> divisorsB1 = new ArrayList<>(64);

                long subtotal = 0;
                for (long u = tId + 1; u <= maxU; u += tCount) {
                    long a = 3 * u - 1;
                    long remaining = LIMIT - a;
                    if (remaining <= 1)
                        continue;

                    factorizeWithSPF((int) u, spf, factorsU);
                    generateDivisors(factorsU, divisorsH);

                    long m = 8 * u - 3;
                    factorizeSquarePart(m, primes, squareFactorsM);
                    generateDivisors(squareFactorsM, divisorsB1);

                    for (long b1 : divisorsB1) {
                        long b1Sq = b1 * b1;
                        long mOver = m / b1Sq;

                        if (b1 >= remaining || b1 + mOver > remaining)
                            continue;

                        long hMax = floorSqrt((remaining - b1) / mOver);
                        if (hMax <= 0)
                            continue;

                        long hMin = 1;
                        long denom = remaining - mOver;
                        if (denom > 0) {
                            hMin = (u * b1 + denom - 1) / denom;
                        }

                        for (long h : divisorsH) {
                            if (h < hMin || h > hMax)
                                continue;
                            if (gcd(h, b1) != 1)
                                continue;

                            long b = (u / h) * b1;
                            long c = h * h * mOver;
                            if (BigIntegerUtil.valueOf(b).add(BigIntegerUtil.valueOf(c))
                                    .compareTo(BigIntegerUtil.valueOf(remaining)) <= 0) {
                                subtotal++;
                            }
                        }
                    }
                }
                return subtotal;
            }));
        }

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

        return String.valueOf(total);
    }

    static class BigIntegerUtil {
        static java.math.BigInteger valueOf(long val) {
            return java.math.BigInteger.valueOf(val);
        }

        static java.math.BigInteger multiply(long a, long b) {
            return valueOf(a).multiply(valueOf(b));
        }
    }

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