// Arup Guha
// 11/9/2025
// Prints out values that are the sums of two perfect squares up to 2000000.

import java.util.*;

public class perfectsquares {

	public static void main(String[] args) {
	
		// We'll store which values are possible here, -1 means not possible.
		int[] other = new int[2000001];
		Arrays.fill(other, -1);
		
		// We are limiting ourselves to solutions where both squares are 1000 or less.
		for (int i=1; i<=1000; i++) {
			for (int j=1; j<=1000; j++) {
				
				// Try it.
				int tot = i*i+j*j;
				
				// Here we stre which value squared allows us to get to tot.
				if (other[tot] == -1) {
					other[tot] = i;
				}
			}
		}
		
		// Here we count how many work.
		int res = 0;
		for (int i=0; i<=2000000; i++)
			if (other[i] != -1)
				res++;
		System.out.println(res);
	}
}