import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

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

    static long countRange(int limit, int aStart, int aEnd) {
        long total = 0;
        for (int a = aStart; a <= aEnd; ++a) {
            int bMax = (limit - a) / 2;
            for (int b = a; b <= bMax; ++b) {
                int s = a + b;
                int cMax = Math.min(s - 1, limit - s);
                if (cMax < b)
                    continue;

                int g = gcd(a, b);
                int step = s / g;
                total += (cMax / step) - ((b - 1) / step);
            }
        }
        return total;
    }

    public static String solve() {
        int limit = 100000;
        int aMax = limit / 3;
        int threads = Runtime.getRuntime().availableProcessors();
        if (threads <= 1) {
            return String.valueOf(countRange(limit, 1, aMax));
        }

        int useThreads = Math.min(threads, aMax);
        int chunk = (aMax + useThreads - 1) / useThreads;

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

        for (int t = 0; t < useThreads; ++t) {
            final int start = t * chunk + 1;
            final int end = Math.min(aMax, start + chunk - 1);
            if (start > end)
                continue;

            futures.add(executor.submit(() -> countRange(limit, start, end)));
        }

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

        return String.valueOf(total);
    }

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