import java.util.*;

public class Euler309 {
    static int gcd(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    static class Pair implements Comparable<Pair> {
        int first, second;

        Pair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        @Override
        public int compareTo(Pair o) {
            if (this.first != o.first)
                return Integer.compare(this.first, o.first);
            return Integer.compare(this.second, o.second);
        }
    }

    static class Triplet {
        int h1, h2, w;

        Triplet(int h1, int h2, int w) {
            this.h1 = h1;
            this.h2 = h2;
            this.w = w;
        }

        @Override
        public boolean equals(Object o) {
            Triplet t = (Triplet) o;
            return h1 == t.h1 && h2 == t.h2 && w == t.w;
        }

        @Override
        public int hashCode() {
            int h = h1;
            h = h * 31 + h2;
            h = h * 31 + w;
            return h;
        }
    }

    public static String solve() {
        int limit = 1000000;
        int lmt = limit - 1;
        List<List<Pair>> byWidth = new ArrayList<>(lmt + 1);
        for (int i = 0; i <= lmt; i++) {
            byWidth.add(new ArrayList<>());
        }

        Set<Triplet> uniq = new HashSet<>();

        int root = (int) Math.sqrt(lmt) + 2;
        for (int i = 1; i <= root; ++i) {
            for (int j = 1; j < i; ++j) {
                if (gcd(i, j) != 1)
                    continue;
                int a = i * i - j * j;
                int b = 2 * i * j;
                int c = i * i + j * j;
                if (a > b) {
                    int temp = a;
                    a = b;
                    b = temp;
                }
                for (int scale = 1; scale * c <= lmt; ++scale) {
                    byWidth.get(a * scale).add(new Pair(b * scale, c * scale));
                    byWidth.get(b * scale).add(new Pair(a * scale, c * scale));
                }
            }
        }

        for (int w = 1; w <= lmt; ++w) {
            List<Pair> vec = byWidth.get(w);
            if (vec.size() < 2)
                continue;
            Collections.sort(vec);
            for (int pIdx = 0; pIdx < vec.size(); ++pIdx) {
                long pf = vec.get(pIdx).first;
                for (int qIdx = 0; qIdx < vec.size(); ++qIdx) {
                    long qf = vec.get(qIdx).first;
                    if (pf == qf)
                        break;
                    if ((pf * qf) % (pf + qf) == 0) {
                        uniq.add(new Triplet((int) qf, (int) pf, w));
                    }
                }
            }
        }

        return String.valueOf(uniq.size());
    }

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