using System; using System.Collections.Generic; using System.Linq; using static Input; public class Prog { private const int INF = 1000000007; private const long INFINITY = 9223372036854775807; public static void Main() { int N = NextInt(); long D = NextLong(); Dictionary xy = new Dictionary(); for (int x = 1; x <= N; x++) for (int y = x; y <= N; y++) { long c = (long)Math.Pow(x, 2) + (long)Math.Pow(y, 2); if (!xy.ContainsKey(c)) xy[c] = 0; if (x != y) xy[c] += 2; else xy[c]++; } long ans = 0; for (int z = 1; z <= N; z++) for (int w = 1; w <= N; w++) { long c = (long)Math.Pow(z, 2) - (long)Math.Pow(w, 2); if (xy.ContainsKey(D - c)) ans += xy[D - c]; } Console.WriteLine(ans); } } public class Input { private static Queue q = new Queue(); private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); } public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); } public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); } public static string NextString() { Confirm(); return q.Dequeue(); } public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); } public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); } public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); } public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); } public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); } }