using System; using System.Collections.Generic; using System.Linq; class C { static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse); static (int, int) Read2() { var a = Read(); return (a[0], a[1]); } static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse); static void Main() => Console.WriteLine(Solve()); static object Solve() { var n = long.Parse(Console.ReadLine()); var n2 = n * n; var p = Enumerable.Range(1, (int)n).Select(x => (long)x * x).ToArray(); var set = p.ToHashSet(); return p.Count(x2 => set.Contains(n2 - x2)); } }