In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states: In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle). The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:a2 + b2 = c2where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.  Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 ≤ a ≤ b ≤ c ≤ n.

The only line contains one integer n (1 ≤ n ≤ 104) as we mentioned above.

Print a single integer — the answer to the problem.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.Threading;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new System.IO.StreamReader(@"..\..\..\in"));
            Console.SetOut(new System.IO.StreamWriter(@"..\..\..\out"));
            for (int testN = 0; testN < 2; testN++)
            {
#endif
                //SetCulture();
                var n = NextInt();
                var n2 = n *n;
                int res = 0;
                for (int a = 1; a <= n; a++)
                {
                    for (int b = a; b <= n; b++)
                    {
                        var c2 = a * a + b * b;
                        var sq2 = (int)Math.Sqrt(c2);
                        if (c2 <= n2 && (sq2*sq2) == c2)
                        {
                            res++;
                        }
                    }
                }

                Console.WriteLine(res);
                //Console.WriteLine(string.Format(NumberFormatInfo.InvariantInfo, "{0:F4}", res));
#if !ONLINE_JUDGE
                Console.ReadLine();
            }
            Console.In.Close();
            Console.Out.Close();
#endif
        }

        private static char[] _defaultSplitter = new char[] { ' ', '\t' };

        private static void SetCulture()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        }

        private static char[] ReadChars(int n)
        {
            char[] buffer = new char[n];
            Console.In.ReadBlock(buffer, 0, n);
            return buffer;
        }

        private static string[] ReadAll()
        {
            return Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadWords()
        {
            return ReadWords(_defaultSplitter);
        }

        private static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        private static int[] ReadInts(char[] splitter)
        {
            return Console.ReadLine().Split(splitter, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        private static int[] ReadInts()
        {
            return ReadInts(_defaultSplitter);
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), NumberFormatInfo.InvariantInfo);
        }

        private static int _pos = 0;
        private static string[] _inputLine = new string[0];

        private static void CheckInputLine()
        {
            if (_pos >= _inputLine.Length)
            {
                _inputLine = ReadWords();
                _pos = 0;
            }
        }

        private static string NextWord()
        {
            CheckInputLine();
            return _inputLine[_pos++];
        }

        private static int NextInt()
        {
            CheckInputLine();
            return int.Parse(_inputLine[_pos++]);
        }

        private static long NextLong()
        {
            CheckInputLine();
            return long.Parse(_inputLine[_pos++]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CF183A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int res = 0;
            for (var a = 1; a < n; a++)
            {
                var bmax = Math.Sqrt(Math.Truncate((double)(n * n - a * a)));
                for (var b = a; b <= bmax; b++)
                {
                    var result = (double)(a * a + b * b);
                    var c = Math.Truncate(result);
                    var cSqr = Math.Sqrt(c);
                    var CTrunc = Math.Truncate(cSqr);
                    if (cSqr == CTrunc && c <= n * n)
                        res++;
                }
            }
            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem304
{
    class Program
    {
        static void Main(string[] args)
        {
            int numb = int.Parse(Console.ReadLine());
            int countResult = 0;

            for (int a = 1; a <= numb; a++)
            {
                int b = a;
                int c = (int)Math.Sqrt(a * a + b * b);

                while (c <= numb && b <= c)
                {
                    if ((a*a + b*b) == (c*c))
                        countResult++;

                    b++;
                    c = (int)Math.Sqrt(a * a + b * b);
                }
            }

            Console.Write(countResult);
        }
    }
}

using System;
class Program_158A
{
    static void Main()
    {
        int n = Convert.ToInt32(Console.ReadLine()), ans = 0;
        for (int i = 2; i < n; i++)
            for (int j = i + 1; j != n; j++)
                if ((Math.Sqrt(i * i + j * j) % 1 == 0) && (Math.Sqrt(i * i + j * j) <= n)) ans++;
        Console.WriteLine(ans);
    }
}

using System;

namespace ConsoleApplication1
{
    public static class MainClass
    {
        static void Main(string[] args)
        {
            var number = int.Parse(Console.ReadLine());

            var result = 0;
            for (var b = 1; b < number; b++)
            {
                for (var a = b + 1; a <= number; a++)
                {
                    var c = Math.Sqrt(a * a - b * b);

                    if (Math.IEEERemainder(c, 1) == 0)
                    {
                        result++;
                    }
                }
            }

            Console.WriteLine(result / 2);
        }
    }
}

using System;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    public static class MainClass
    {
        static void Main(string[] args)
        {
            var number = int.Parse(Console.ReadLine());

            var result = 0;
            Parallel.For(1, number, b =>
                {
                    for (var a = b + 1; a <= number; a++)
                    {
                        var c = Math.Sqrt(a * a - b * b);

                        if (Math.IEEERemainder(c, 1) == 0)
                        {
                            result++;
                        }
                    }
                });

            Console.WriteLine(result / 2);
        }
    }
}

using System;

class P {
  static void Main() {
    var n = int.Parse(Console.ReadLine());
    var res = 0;
    for (var c = n; c >= 1; c--) for (var b = c ; b >= 1 ; b--) {
      var sa = c*c-b*b;
      var a = (int)Math.Sqrt(sa);
      if ((a*a == sa && a >= 1 && a <= b) || (a*a+2*a+1==sa &&a+1>=1 &&a+1 <=b)) res++;
    }
    Console.Write(res);
  }
}

using System;
using System.IO;
using System.Text;

namespace Pythagorean_Theorem
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();

            var nn = new int[n + 1];
            for (int i = 0; i <= n; i++)
            {
                nn[i] = i*i;
            }

            int count = 0;
            for (int c = 1; c <= n; c++)
            {
                for (int b = c-1; b > 0; b--)
                {
                    int a = nn[c] - nn[b];
                    if (a <= nn[b])
                    {
                        if (Array.BinarySearch(nn, a) > 0)
                            count++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Numerics;

class Program
{
    static TextReader reader;
    static TextWriter writer;
    const double EPS = 1e-7;
    static Program()
    {
#if ONLINE_JUDGE
        reader = Console.In;
        writer = Console.Out;
#else
        reader = new StreamReader("input.txt");
        writer = new StreamWriter("output.txt");
#endif
    }
    static long gcd(long a, long b)
    {
        return (b != 0) ? gcd(b, a % b) : a;
    }
    static void swap(ref int a, ref int b)
    {
        int t = a;
        a = b;
        b = t;
    }
    static long pow(long a, long x, long mod)
    {
        long res = 1;
        while (x > 0)
        {
            if ((x & 1) == 1)
            {
                res = (res * a) % mod;
                --x;
            }
            else
            {
                a = (a * a) % mod;
                x >>= 1;
            }
        }
        return res;
    }
    static void _a()
    {
        int n = int.Parse(reader.ReadLine());
        //SortedSet<int> p = new SortedSet<int>();
        Dictionary<int, bool> p = new Dictionary<int, bool>();
        for (int i = 1; i <= n; ++i)
            p.Add(i * i, true);//p[i * i] = 1;//p.Add(i*i);
        int count = 0;
        for (int i = 1; i <= n; ++i)//foreach (int p1 in p)
        {
            for (int j = 1; j < i; ++j)//foreach (int p2 in p)
            {
                int p1 = i * i, p2 = j * j;
                if (p2 > p1 / 2)
                    break;
                if (p.ContainsKey(p1-p2))//(p.Contains(p1 - p2))
                    ++count;
            }
        }
        writer.Write(count);
    }
    static void _b()
    {

    }
    static void _c()
    {

    }
    static void _d()
    {

    }
    static void Main(string[] args)
    {
        _a();
        reader.Close();
        writer.Close();
    }
}

using System;

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int j = i; j <= n; j++)
                {
                    int temp = i * i + j * j;
                    int t = (int)Math.Sqrt(temp);
                    if (t * t - temp == 0 && t <= n)
                        count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

/*
 * Сделано в SharpDevelop.
 * Пользователь: admin
 * Дата: 01.02.2013
 * Время: 22:20
 *
 * Для изменения этого шаблона используйте Сервис | Настройка | Кодирование | Правка стандартных заголовков.
 */

using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System;

namespace reshenie
{
	class Program
	{
		public static int ReadInt(){

				return int.Parse(Console.ReadLine());

			}

		public static string[] ReadStrArr(){

				return Console.ReadLine().Split(' ');

			}

	    public static int ToInt(Object a){

			return int.Parse(a.ToString());

			}

		public static void print(int[] mas){

		for (int i =0;i<mas.Length;i++)
			Console.Write(mas[i].ToString()+" ");

		}

		public static int[] ReadIntArray(int n,string[] s){
			int[] a = new int[n];
			for(int i =0;i<n;i++){

				a[i]= ToInt(s[i]);
			}
		return a;
		}
		/*

		 */
		public static void Main(string[] args)
		{
			int n= ReadInt();
			int ans=0;
			for (int c = 1; c <=n; c++)
			{
				for (int b = 1; b <c; b++)

				{
					double q =Math.Sqrt(c*c-b*b);

					if( (q-(int)q)<=0.0000001 && (q<=b)) ans++;

				}
			}

			Console.WriteLine(ans);
		//	Console.ReadKey(true);
		}
	}
}

using System;
using System.Collections.Generic;
using System.IO;

namespace prA {

    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif
        static void Main(string[] args) {
            int n = Next();
            int ans = 0;
            for(int a = 1; a <= n; a++) {
                for(int b = a; b <= n; b++) {
                    long c2 = (long) a * a + (long) b * b;
                    long c = (long) Math.Sqrt(c2);
                    if(c * c != c2)
                        continue;
                    if(c > n)
                        continue;
                    ans++;
                }
            }
            writer.Write(ans);
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

#define Online
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);
    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            int n = ReadInt();
            long ans = 0;
            HashSet<int> hs = new HashSet<int>();
            for (int i = 1; i <= n; i++)
                hs.Add(i * i);
            for (int c = 1; c <= n; c++)
            {
                for (int a = 1; ; a++)
                {
                    if (a * a > (c * c - a * a)) break;
                    if (hs.Contains(c * c - a * a)) ans++;
                }
            }
            Console.WriteLine(ans);

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }
    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }
    class Graph
    {
        public List<List<int>> g = new List<List<int>>();
        public List<Edge> e = new List<Edge>();
        public Stack<int> s;
        public List<bool> u;
        public List<int> d; //длина
        public List<int> p; //путь
        public Queue<int> q;
        public int n;
        public int start;
        public int finish;
        public Graph(int n)
        {
            for (int i = 0; i <= n; i++)
                g.Add(new List<int>());
            p = new List<int>();
            d = new List<int>();
            for (int i = 0; i <= n; i++)
                p.Add(-1);
            for (int i = 0; i <= n; i++)
                d.Add(-1);
            u = new List<bool>();
            for (int i = 0; i <= n; i++)
                u.Add(true);
            this.n = n;
        }

        public bool dfs1(int v)
        {
            u[v] = false;
            for (int i = 0; i < g[v].Count; i++)
            {
                if (u[g[v][i]])
                {
                    p[g[v][i]] = v;
                    if (dfs1(g[v][i])) return true;
                }
                else
                {
                    if (p[v] != g[v][i])
                    {
                        start = v;
                        finish = g[v][i];
                        return true;
                    }
                }
            }
            return false;
        }

        public void dfs2(int v)
        {
            s = new Stack<int>();
            s.Push(v);
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();
                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (d[g[cur][i]] == -1)
                    {
                        s.Push(g[cur][i]);
                        d[g[cur][i]] = d[cur] + 1;
                        all = false;
                    }
                }
                if (all)
                    s.Pop();
            }
        }

        public void DFS(int v)
        {
            s = new Stack<int>();

            s.Push(v);
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();
                u[cur] = false;
                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (u[g[cur][i]])
                    {
                        all = false;
                        p[g[cur][i]] = cur;
                        s.Push(g[cur][i]);
                    }
                    else
                    {
                        if (p[cur] != g[cur][i])
                        {
                            start = cur;
                            finish = g[cur][i];
                            return;
                        }
                    }
                }
                if (all)
                    s.Pop();
            }
        }

        public void BFS(params int[] v)
        {
            q = new Queue<int>();
            u = new List<bool>();
            d = new List<int>();
            p = new List<int>();

            for (int i = 0; i <= n; i++)
            {
                u.Add(true);
                d.Add(0);
                p.Add(0);
            }

            q.Enqueue(v[0]);
            u[v[0]] = false;
            int cur;

            while (q.Count != 0)
            {
                cur = q.Dequeue();
                for (int i = 0; i < g[cur].Count; i++)
                    if (u[g[cur][i]])
                    {
                        q.Enqueue(g[cur][i]);
                        u[g[cur][i]] = false;
                        p[g[cur][i]] = cur;
                        d[g[cur][i]] = d[cur] + 1;
                    }
            }

            int from = v[1];
            string path = from + "";
            while (p[from] != 0)
            {
                path = p[from] + " " + path;
                from = p[from];
            }
            Console.WriteLine(d[v[1]] + " : " + path);
        }

        public void FordBellman(params int[] v)
        {
            d = new List<int>();
            p = new List<int>();
            for (int i = 0; i <= n; i++)
            {
                d.Add(int.MaxValue);
                p.Add(0);
            }
            d[v[0]] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < e.Count; j++)
                {
                    if (d[e[j].a] != int.MaxValue)
                    {
                        if (d[e[j].a] + e[j].w < d[e[j].b])
                        {
                            d[e[j].b] = d[e[j].a] + e[j].w;
                            p[e[j].b] = e[j].a;
                        }
                    }
                }
            }

            int from = v[1];

            if (d[from] == int.MaxValue)
            {
                Console.WriteLine("Can't find the minimal path");
                return;
            }

            string ans = from + "";
            while (p[from] != 0)
            {
                ans = p[from] + " " + ans;
                from = p[from];
            }

            Console.WriteLine(d[v[1]] + " : " + ans);
        }
    }
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);//
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}

#define Online
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace CF
{
    delegate double F(double x);
    delegate decimal Fdec(decimal x);
    class Program
    {

        static void Main(string[] args)
        {

#if FileIO
            StreamReader sr = new StreamReader("input.txt");
            StreamWriter sw = new StreamWriter("output.txt");
            Console.SetIn(sr);
            Console.SetOut(sw);
#endif

            int n = ReadInt();
            long ans = 0;
            HashSet<int> hs = new HashSet<int>();
            for (int i = 1; i <= n; i++)
                hs.Add(i * i);
            for (int c = 1; c <= n; c++)
            {
                for (int a = 1; ; a++)
                {
                    if (a * a > (c * c - a * a)) break;
                    if (hs.Contains(c * c - a * a)) ans++;
                }
            }
            Console.WriteLine(ans);

#if Online
            Console.ReadLine();
#endif

#if FileIO
            sr.Close();
            sw.Close();
#endif
        }

        static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
    }

    public static class MyMath
    {
        public static long BinPow(long a, long n, long mod)
        {
            long res = 1;
            while (n > 0)
            {
                if ((n & 1) == 1)
                {
                    res = (res * a) % mod;
                }
                a = (a * a) % mod;
                n >>= 1;
            }
            return res;
        }
    }

    public class SegmentTree
    {
        int[] v_min;
        int[] v_max;
        int[] mas;
        public void BuildTree(int[] a)
        {
            int n = a.Length - 1;
            int z = 0;
            while (n >= 2)
            {
                z++;
                n >>= 1;
            }
            n = 1 << (z + 1);
            v_min = new int[n << 1];
            v_max = new int[n << 1];
            mas = new int[n << 1];
            for (int i = n; i < n + a.Length; i++)
                v_min[i] = a[i - n];
            for (int i = n + a.Length; i < v_min.Length; i++)
                v_min[i] = int.MaxValue;
            for (int i = n - 1; i > 0; i--)
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);

            for (int i = n; i < n + a.Length; i++)
                v_max[i] = a[i - n];
            for (int i = n + a.Length; i < v_max.Length; i++)
                v_max[i] = int.MinValue;
            for (int i = n - 1; i > 0; i--)
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);

        }
        //nil
        public int RMQ_MIN(int l, int r)
        {
            int ans = int.MaxValue;
            l += v_min.Length >> 1;
            r += v_min.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Min(ans, v_min[l]);
                if (!((r & 1) == 0))
                    ans = Math.Min(ans, v_min[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public int RMQ_MAX(int l, int r)
        {
            int ans = int.MinValue;
            l += v_max.Length >> 1;
            r += v_max.Length >> 1;
            const int o = 1;
            while (l <= r)
            {
                if ((l & 1) == o)
                    ans = Math.Max(ans, v_max[l]);
                if (!((r & 1) == 0))
                    ans = Math.Max(ans, v_max[r]);
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
            return ans;
        }

        public void Put(int l, int r, int op)
        {
            l += mas.Length >> 1;
            r += mas.Length >> 1;
            while (l <= r)
            {
                if (l % 2 != 0)
                    mas[l] = op;
                if (r % 2 == 0)
                    mas[r] = op;
                l = (l + 1) >> 1;
                r = (r - 1) >> 1;
            }
        }

        public int Get(int x)
        {
            x += mas.Length >> 1;
            int ans = int.MinValue;
            while (x > 0)
            {
                ans = Math.Max(mas[x], ans);
                x >>= 1;
            }
            return ans;
        }

        public void Update(int i, int x)
        {
            i += v_min.Length >> 1;
            v_min[i] = x;
            v_max[i] = x;
            i >>= 1;
            while (i > 0)
            {
                v_min[i] = Math.Min(v_min[(i << 1)], v_min[(i << 1) + 1]);
                v_max[i] = Math.Max(v_max[(i << 1)], v_max[(i << 1) + 1]);
                i >>= 1;
            }
        }
    }
    class Edge
    {
        public int a;
        public int b;
        public int w;

        public Edge(int a, int b, int w)
        {
            this.a = a;
            this.b = b;
            this.w = w;
        }
    }
    class Graph
    {
        public List<List<int>> g = new List<List<int>>();
        public List<Edge> e = new List<Edge>();
        public Stack<int> s;
        public List<bool> u;
        public List<int> d; //длина
        public List<int> p; //путь
        public Queue<int> q;
        public int n;
        public int start;
        public int finish;
        public Graph(int n)
        {
            for (int i = 0; i <= n; i++)
                g.Add(new List<int>());
            p = new List<int>();
            d = new List<int>();
            for (int i = 0; i <= n; i++)
                p.Add(-1);
            for (int i = 0; i <= n; i++)
                d.Add(-1);
            u = new List<bool>();
            for (int i = 0; i <= n; i++)
                u.Add(true);
            this.n = n;
        }

        public bool dfs1(int v)
        {
            u[v] = false;
            for (int i = 0; i < g[v].Count; i++)
            {
                if (u[g[v][i]])
                {
                    p[g[v][i]] = v;
                    if (dfs1(g[v][i])) return true;
                }
                else
                {
                    if (p[v] != g[v][i])
                    {
                        start = v;
                        finish = g[v][i];
                        return true;
                    }
                }
            }
            return false;
        }

        public void dfs2(int v)
        {
            s = new Stack<int>();
            s.Push(v);
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();
                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (d[g[cur][i]] == -1)
                    {
                        s.Push(g[cur][i]);
                        d[g[cur][i]] = d[cur] + 1;
                        all = false;
                    }
                }
                if (all)
                    s.Pop();
            }
        }

        public void DFS(int v)
        {
            s = new Stack<int>();

            s.Push(v);
            int cur;
            bool all;
            while (s.Count != 0)
            {
                cur = s.Peek();
                u[cur] = false;
                all = true;
                for (int i = 0; i < g[cur].Count; i++)
                {
                    if (u[g[cur][i]])
                    {
                        all = false;
                        p[g[cur][i]] = cur;
                        s.Push(g[cur][i]);
                    }
                    else
                    {
                        if (p[cur] != g[cur][i])
                        {
                            start = cur;
                            finish = g[cur][i];
                            return;
                        }
                    }
                }
                if (all)
                    s.Pop();
            }
        }

        public void BFS(params int[] v)
        {
            q = new Queue<int>();
            u = new List<bool>();
            d = new List<int>();
            p = new List<int>();

            for (int i = 0; i <= n; i++)
            {
                u.Add(true);
                d.Add(0);
                p.Add(0);
            }

            q.Enqueue(v[0]);
            u[v[0]] = false;
            int cur;

            while (q.Count != 0)
            {
                cur = q.Dequeue();
                for (int i = 0; i < g[cur].Count; i++)
                    if (u[g[cur][i]])
                    {
                        q.Enqueue(g[cur][i]);
                        u[g[cur][i]] = false;
                        p[g[cur][i]] = cur;
                        d[g[cur][i]] = d[cur] + 1;
                    }
            }

            int from = v[1];
            string path = from + "";
            while (p[from] != 0)
            {
                path = p[from] + " " + path;
                from = p[from];
            }
            Console.WriteLine(d[v[1]] + " : " + path);
        }

        public void FordBellman(params int[] v)
        {
            d = new List<int>();
            p = new List<int>();
            for (int i = 0; i <= n; i++)
            {
                d.Add(int.MaxValue);
                p.Add(0);
            }
            d[v[0]] = 0;

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < e.Count; j++)
                {
                    if (d[e[j].a] != int.MaxValue)
                    {
                        if (d[e[j].a] + e[j].w < d[e[j].b])
                        {
                            d[e[j].b] = d[e[j].a] + e[j].w;
                            p[e[j].b] = e[j].a;
                        }
                    }
                }
            }

            int from = v[1];

            if (d[from] == int.MaxValue)
            {
                Console.WriteLine("Can't find the minimal path");
                return;
            }

            string ans = from + "";
            while (p[from] != 0)
            {
                ans = p[from] + " " + ans;
                from = p[from];
            }

            Console.WriteLine(d[v[1]] + " : " + ans);
        }
    }
    static class ArrayUtils
    {
        public static int BinarySearch(int[] a, int val)
        {
            int left = 0;
            int right = a.Length - 1;
            int mid;

            while (left < right)
            {
                mid = left + ((right - left) >> 1);
                if (val <= a[mid])
                {
                    right = mid;
                }
                else
                {
                    left = mid + 1;
                }
            }

            if (a[left] == val)
                return left;
            else
                return -1;
        }

        public static double Bisection(F f, double left, double right, double eps)
        {
            double mid;
            while (right - left > eps)
            {
                mid = left + ((right - left) / 2d);
                if (Math.Sign(f(mid)) != Math.Sign(f(left)))
                    right = mid;
                else
                    left = mid;
            }
            return (left + right) / 2d;
        }

        public static decimal TernarySearchDec(Fdec f, decimal eps, decimal l, decimal r, bool isMax)
        {
            decimal m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3m;
                m2 = r - (r - l) / 3m;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static double TernarySearch(F f, double eps, double l, double r, bool isMax)
        {
            double m1, m2;
            while (r - l > eps)
            {
                m1 = l + (r - l) / 3d;
                m2 = r - (r - l) / 3d;
                if (f(m1) < f(m2))
                    if (isMax)
                        l = m1;
                    else
                        r = m2;
                else
                    if (isMax)
                        r = m2;
                    else
                        l = m1;
            }
            return r;
        }

        public static void Merge<T>(T[] A, int p, int q, int r, T[] L, T[] R) where T : IComparable<T>
        {
            for (int i = p; i <= q; i++)
                L[i] = A[i];
            for (int i = q + 1; i <= r; i++)
                R[i] = A[i];

            for (int k = p, i = p, j = q + 1; k <= r; k++)
            {
                if (i > q)
                {
                    for (; k <= r; k++, j++)
                        A[k] = R[j];
                    return;
                }
                if (j > r)
                {
                    for (; k <= r; k++, i++)
                        A[k] = L[i];
                    return;
                }
                if (L[i].CompareTo(R[j]) <= 0)
                {
                    A[k] = L[i];
                    i++;
                }
                else
                {
                    A[k] = R[j];
                    j++;
                }
            }
        }

        public static void Merge_Sort<T>(T[] A, int p, int r, T[] L, T[] R) where T : IComparable<T>
        {
            if (p >= r) return;
            int q = p + ((r - p) >> 1);
            Merge_Sort(A, p, q, L, R);
            Merge_Sort(A, q + 1, r, L, R);
            Merge(A, p, q, r, L, R);
        }

        static void Shake<T>(T[] a)
        {
            Random rnd = new Random(Environment.TickCount);
            T temp;
            int b, c;
            for (int i = 0; i < a.Length; i++)
            {
                b = rnd.Next(0, a.Length);
                c = rnd.Next(0, a.Length);
                temp = a[b];
                a[b] = a[c];
                a[c] = temp;
            }
        }
    }
}

using System;

    class Program
    {
        static void Main(string[] args)
        {int an = 0;

            for (float n = Convert.ToInt32(Console.ReadLine()); n > 0; n--) {

                for (float a = 1; a <= Math.Sqrt(n*n / 2); a++) {
                double b = Math.Sqrt(n*n-a*a);
                if ((b % 1.0) == 0) an++;

                }

            }

            Console.WriteLine(an);

        }
    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _304A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int results = 0;
            for (int b = 1; b < n; b++)
            {
                for (int a = 1; a <= b; a++)
                {
                    if ((double)Math.Sqrt(a * a + b * b) == (int)Math.Sqrt(a * a + b * b) && Math.Sqrt(a * a + b * b) <= n)
                    {
                        results++;
                    }
                }
            }
            Console.Write(results);
        }
    }
}

using System;
class Program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var c = 0;
        for (int i = 2; i < n; i++)
            for (int j = i; j < n; j++)
                if (Math.Sqrt(i * i + j * j) <= n && Math.Sqrt(i * i + j * j) == (int)Math.Sqrt(i * i + j * j)) c++;
        Console.WriteLine(c);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace ConsoleApplication27
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int res = 0;
            for (int a = 1; a <= n; a++)
               for (int b = 1; b <= n; b++){
                       var c = Math.Sqrt(a * a + b * b);
                       if ((c <= n) && (c - Math.Truncate(c) == 0) && (a <= b) && (b <= c))
                           res += 1;
                       }
            Console.WriteLine(res);

            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans=0,check,K1,V,N = int.Parse(Console.ReadLine());
            double try1;

            for(int i=1;i<=N;++i)
                for (int j = i; j <= N; ++j)
                    {
                        V = i * i + j * j;
                        try1 = Math.Sqrt(V);
                        check = Convert.ToInt32(try1);
                        if (check * check == V)
                        {
                            if (check <= N) ++ans;
                        }
                        else
                        {
                            ++check;
                            if (check * check == V && check <= N) ++ans;
                        }
                    }

            Console.WriteLine("{0}",ans);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Теорема_Пифагора_II
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 n;
            n = Convert.ToInt64(Console.ReadLine());
            Int64 sqn = n * n;
            Int64 a, b, c, ret = 0;
            double sqc;
            for (a = 1; a <= n; a++)
                for (b = a; b <= n; b++)
                {
                    c = a * a + b * b;
                    sqc = Math.Sqrt(c);
                    if (c <= sqn)
                    {
                        if ((int)sqc == sqc) ret++;
                    }
                    else break;
                }
            Console.Write(ret);

        }
    }
}

using System;

class Program
{
    static void Main(string[] args)
    {
        int n;
        n = Convert.ToInt32(Console.ReadLine());
        int a, b, Count = 0;
        for (a = 1; a <= n; a++)
            for (b = a; b <= n; b++)
                if ((Math.Sqrt(a * a + b * b) == Math.Round(Math.Sqrt(a * a + b * b))) && (Math.Sqrt(a * a + b * b) <= n))
                    Count++;
        Console.WriteLine(Count);
        Console.ReadLine();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace codeforces
{
	class Program
	{
		public const int Osn = 1000000007;

		public class Pair
		{
			public long First;

			public long Second;
		}

		public class Ppair
		{
			public char Symbol;

			public int Count;
		}

		public class PairComparer : IComparer<Pair>
		{
			public int Compare(Pair x, Pair y)
			{
				if (x.First < y.First || (x.First == y.First && x.Second > y.Second))
					return -1;
				return 1;
			}
		}

		public static long GetGcd(long a, long b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;

			}
		}

		public static int GetGcd(int a, int b)
		{
			while (true)
			{
				if (b == 0)
					return a;
				var a1 = a;
				a = b;
				b = a1 % b;

			}
		}

		public static void WriteYesNo(bool x, string yes = "YES", string no = "NO")
		{
			Console.WriteLine(x ? yes : no);
		}

		public static string ReadString()
		{
			return Console.ReadLine();
		}

		public static List<int> ReadListOfInts()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static List<long> ReadListOfLongs()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(long.Parse).ToList();
		}

		public static int ReadInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static long ReadLong()
		{
			var s = Console.ReadLine();
			return long.Parse(s);
		}

		public class Edge
		{
			public int Color;

			public int To;
		}

		public class Vertex
		{
			public int Was;

			public List<Edge> Edges;

			public Vertex()
			{
				Was = 0;
				Edges = new List<Edge>();
			}
		}

		public static List<Vertex> Graph = new List<Vertex>();

		public static void Dfs(int u, int c)
		{
			Graph[u].Was = 1;
			foreach (var t in Graph[u].Edges.Where(x => x.Color == c && Graph[x.To].Was == 0))
			{
				Dfs(t.To, c);
			}

		}

		public static bool IsPrime(long x)
		{
			for (var j = 2; j * j <= x; ++j)
				if (x % j == 0)
					return false;
			return true;
		}

		public class LinkedVertex
		{
			public int Next;

			public int Prev;

			public int Value;
		}

		public static int BinarySearch(List<int> list, int value)
		{
			var l = -1;
			var r = list.Count;
			while (r - l > 1)
			{
				var m = (r + l) / 2;
				if (list[m] >= value)
					r = m;
				else
					l = m;
			}

			return r;
		}

		public static Dictionary<long, long> mp = new Dictionary<long, long>();
		public static long Go(long u, long v, long w)
		{
			long ans = 0;
			while (u != v)
				if (u > v)
				{
					if (!mp.ContainsKey(u))
						mp.Add(u, 0);
					ans += mp[u];
					mp[u] += w;
					u /= 2;
				}
				else
				{
					if (!mp.ContainsKey(v))
						mp.Add(v, 0);
					ans += mp[v];
					mp[v] += w;
					v /= 2;
				}
			return ans;
		}

		public static int GetAns(int x, int pow)
		{
			if (pow == 0)
				return 1;
			if (pow % 2 == 1)
				return (GetAns(x, pow - 1) * 8) % 10;
			var t = GetAns(x, pow / 2);
			return (t * t) % 10;
		}

		private static void Main()
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var n = ReadInt();
			var ans = 0;
			for (var i = 1; i <= n; ++i)
			{
				for (var j = i; j <= n; ++j)
				{
					var x = i * i + j * j;
					var xx = (int)Math.Sqrt(x);
					if (x == xx * xx && xx <= n)
						ans++;
				}
			}
			Console.WriteLine(ans);
			Console.ReadLine();
			/*			input.Close();
			output.Close();*/
		}
	}
}

using System;
using System.Collections.Generic;
using System.Text;

namespace ACM
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int ans = 0;
            for(int i=1;i<=n;++i)
                for (int j = i; j <= n; ++j)
                {
                    int c = i * i + j * j;
                    int t = (int)Math.Sqrt(c+1e-5);
                    if (t*t==c && t >= j && t<=n) ans++;
                }
            Console.WriteLine(ans);
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace MakeCalendar
{
    public static class MainClass
    {

        static int ReadIntLine()
        {
            return int.Parse(Console.ReadLine());
        }

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static void Main(string[] args)
        {
            int ub = ReadIntLine();
            int k = (int)Math.Ceiling(Math.Sqrt(ub));

            HashSet<string> set = new HashSet<string>();

            for (int m = 1; m < k; m++)
            {
                for (int n = 1; n < m; n++)
                {
                    if (gcd(n, m) == 1)
                    {
                        int c = m * m + n * n;
                        int b = Math.Max(m * m - n * n,2*m*n);
                        int a = Math.Min(m * m - n * n, 2 * m * n);

                        int cc = c, bb = b, aa = a;

                        while (cc<=ub)
                        {
                            //PrintLn(aa,bb,cc);
                            set.Add(aa + "," + bb);
                            aa += a;
                            bb += b;
                            cc += c;
                        }
                    }
                }
            }

            PrintLn(set.Count);

        }

    }

}

using System;
using System.Collections.Generic;
using System.Text;

namespace codenoobs_studio_hammer_man_69
{
    class Program
    {
        static void Main(string[] args)
        {
            //var Watch = new System.Diagnostics.Stopwatch();

            double n = int.Parse(Console.ReadLine());

            //Watch.Start();

            int count = 0;
            for (int q = 1; q < Math.Sqrt(n/2); q++) {
                for (int p = q + 1; p <= Math.Sqrt(n - q * q); p++) {
                    if (Coprime(p, q) && p % 2 != q % 2) {
                        count += (int) Math.Floor(n/(p*p + q*q));
                    }
                }
            }

            Console.WriteLine(count);
            //Watch.Stop();
            //Console.WriteLine(Watch.ElapsedMilliseconds);

        }

        static bool Coprime(int m, int n) {
            if (m == 1 || n == 1) return true;
            if (m == 0 || n == 0) return false;

            if (m < n) return Coprime(m, n % m);
            return Coprime(m % n, n);
        }
    }
}

using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program {
	static void Main() {
		int n = int.Parse(Console.ReadLine());
		int[] a = new int[10001];
		for(int i = 1; i < a.Length; i++){
			a[i] = i * i;
		}
		int c = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				double tmp = Math.Sqrt(a[i] + a[j]);
				if(a[i] > a[j] && tmp % 1 == 0){
					if(tmp <= n){
						c++;
					}
				}
			}
		}
		Console.WriteLine(c);
	}
}

/*
 * Created by SharpDevelop.
 * User: IdM
 * Date: 12.05.2013
 * Time: 16:43
 *
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace r183_1
{
	class Program
	{
		public static void Main(string[] args)
		{
			string str = Console.ReadLine();
			int n = int.Parse(str);
			int cnt = 0;

			for (int i = 1; i <= n; i++) {
				for (int j = i; j <= n; j++) {
					double fl = Math.Sqrt((i*i + j*j));
					if (fl == (int)fl) {
						cnt++;
					}
					if (fl > n) {
						break;
					}

				}
			}

			Console.WriteLine(cnt);

//			Console.Write("Press any key to continue . . . ");
//			Console.ReadKey(true);
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Dictionary<int, int> dic = new Dictionary<int, int>();
            int res = 0;
            for (int i = 1; i <= n; i++)
                dic.Add(i * i, i);
            for (int i = 1; i < n; i++)
                for (int j = i + 1; j < n; j++)
                    if (dic.ContainsKey(i * i + j * j)) res++;
            Console.WriteLine(res.ToString());
        }
    }
}

using System;

namespace CSharp
{
    class _304A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());

            int count = 0;

            for (int a = 1; a <= n; a++)
            {
                for (int b = a; b <= n; b++)
                {
                    int c = (int)Math.Sqrt(a * a + b * b);

                    if (c <= n && a * a + b * b == c * c)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace ConsoleApplication30
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            // end Isqrt()

            int n = ReadInt();
            int counter = 0;
//            int n = (int)Math.Ceiling(Math.Sqrt(t));
            for (int a = 1; a <= n; a++)
            {
                for (int b = a; b <= n; b++)
                {
                    double issqrt = Math.Sqrt(a*a + b*b);
                    if (issqrt %1 == 0 && issqrt * issqrt == (a * a + b * b) && issqrt <= n)
                    {
                        counter++;
                    }

//                    }
                }
            }
            Console.WriteLine(counter);
            Console.ReadLine();
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read(out int n1, out int n2)
        {
            string[] input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
        }

        private static void Read(out int n1, out int n2, out int n3)
        {
            string[] input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
            n3 = int.Parse(input[2]);
        }

        private static void Read(out int n1, out int n2, out int n3, out int n4)
        {
            string[] input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
            n3 = int.Parse(input[2]);
            n4 = int.Parse(input[3]);
        }

        private static void Read<T>(out T a1, out T a2)
        {
            string[] input = ReadArray();
            a1 = (T) Convert.ChangeType(input[0], typeof (T));
            a2 = (T) Convert.ChangeType(input[1], typeof (T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3)
        {
            string[] input = ReadArray();
            a1 = (T) Convert.ChangeType(input[0], typeof (T));
            a2 = (T) Convert.ChangeType(input[1], typeof (T));
            a3 = (T) Convert.ChangeType(input[2], typeof (T));
        }

        private static void Read<T>(out T a1, out T a2, out T a3, out T a4)
        {
            string[] input = ReadArray();
            a1 = (T) Convert.ChangeType(input[0], typeof (T));
            a2 = (T) Convert.ChangeType(input[1], typeof (T));
            a3 = (T) Convert.ChangeType(input[2], typeof (T));
            a4 = (T) Convert.ChangeType(input[3], typeof (T));
        }

        private static int ReadInt()
        {
            return Int32.Parse(Read());
        }

        private static long ReadLong()
        {
            return long.Parse(Read());
        }

        private static double ReadDouble()
        {
            return double.Parse(Read(), CultureInfo.InvariantCulture);
        }

        private static T Read<T>()
        {
            return (T) Convert.ChangeType(Read(), typeof (T));
        }

        private static string[] ReadArray()
        {
            string readLine = Console.ReadLine();
            if (readLine != null)
                return readLine.Split(' ');

            throw new ArgumentException();
        }

        private static List<int> ReadIntArray()
        {
            return ReadArray().Select(Int32.Parse).ToList();
        }

        private static List<long> ReadLongArray()
        {
            return ReadArray().Select(long.Parse).ToList();
        }

        private static List<double> ReadDoubleArray()
        {
            return ReadArray().Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static List<T> ReadArray<T>()
        {
            return ReadArray().Select(x => (T) Convert.ChangeType(x, typeof (T))).ToList();
        }

        private static void WriteLine(int value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(long value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void WriteLine<T>(T value)
        {
            Console.WriteLine(value);
        }

        private static void Write(int value)
        {
            Console.Write(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(long value)
        {
            Console.Write(value);
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write<T>(T value)
        {
            Console.Write(value);
        }

        #endregion
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class A
    {
        public void Run()
        {
            int n = int.Parse(Console.ReadLine());
            ulong re = 0, of = 0;
            //int[] m = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            //string str = Console.ReadLine();

            for (int k = 1; k <= n; k++)
            {
                for (int i = 1; i <= 10000; i++)
                {
                    int j = k * k - i * i;
                    var sqr = (int)Math.Sqrt(j);

                    if ((j > 0) && (j == sqr * sqr))
                    {
                        re+=1;
                        if (sqr != i)
                        {
                            of+=1;
                        }
                    }
                    else
                        if (j < 0)
                        {
                            break;
                        }
                }
            }
            ulong rez = re - of/2;

            Console.Write(rez);
        }
    }
    class B
    {
        public void Run()
        {
            int[] str = Console.ReadLine().Split(':').Select(a => int.Parse(a)).ToArray();
            int[] str2 = Console.ReadLine().Split(':').Select(a => int.Parse(a)).ToArray();

            DateTime d1 = new DateTime(str[0], str[1], str[2]);
            DateTime d2 = new DateTime(str2[0], str2[1], str2[2]);

            TimeSpan ts = d2 - d1;

            Console.WriteLine(Math.Abs(ts.Days));
        }
    }

    class Programm
    {
        static void Main(string[] args)
        {
            A a = new A();
            a.Run();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class R183_Div2_A
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            int a,b,c, cnt=0;
            int x;
            for (a = 1; a <= num; a++)
                for (b = a+1; b <= num; b++)
                {
                    c = a * a + b * b;
                    x = (int)(Math.Sqrt((double)c) + 1e-8);
                    if (x * x == c && x <= num)
                    {
                        //Console.WriteLine(a + " " + b + " " + x);
                        cnt++;
                    }
                }
            Console.WriteLine(cnt);
        }
    }
}

using System;
using System.Collections.Generic;

namespace codeforces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int n = Convert.ToInt32 (Console.ReadLine ());

            int ans = 0;

            for(int i = 1;i <= n; i++)
                for (int j = i; j <= n; ++j)
                {
                    int c = i * i + j * j;
                    int t = (int)Math.Sqrt(c + 1e-5);
                    if (t * t == c && t >= j && t <= n) ans++;
                }
            Console.WriteLine(ans);
		}
	}
}

using System;
using System.Linq;
class Program_158A
{
    static void Main()
    {
        int[] a = new int[0];
        int b = Convert.ToInt32(Console.ReadLine()), sum = 0;
        int bound = (int)(Math.Sqrt(b));
        for (int i = 1; i < bound; i++)
            for (int j = i + 1; j < bound; j++)
            {

                if ((IsPrime(i) | IsPrime(j)) & ((j - i) % 2 == 1) & (j % i != (i == 1 ? 1 : 0)))
                {
                    Array.Resize(ref a, a.Length + 1);
                    a[a.Length - 1] = i * i + j * j;
                }
            }
        a = a.Select(x => x).Where(x => x <= b).ToArray();
        Array.Sort(a);
        for (int i = 0; i < a.Length; sum += b / a[i++]) ;
        Console.WriteLine(sum);
    }
    static bool IsPrime(int x)
    {
        for (int ii = 2; ii <= x / ii; ii++)
            if ((x % ii) == 0) return false;
        return true;
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = Convert.ToInt32(Console.ReadLine());
            int a, b, Count = 0;
            for (a = 1; a <= n; a++)
                for (b = a; b <= n; b++)
                    if (Math.Sqrt(a * a + b * b) <= n) Count++;
            Console.WriteLine(Count);
        }
    }
}

using System;

class Program {
    static void Main(string[] args) {
        double n = int.Parse(Console.ReadLine());
        int count = 0;
        for (int q = 1; q < Math.Sqrt(n/2); q++) {
            for (int p = q + 1; p <= Math.Sqrt(n - q * q); p++) {
                if (Coprime(p, q) && p % 2 != q % 2) {
                    count += (int) Math.Floor(n/(p*p + q*q));
                }
            }
        }
    }

    static bool Coprime(int m, int n) {
        if (m == 1 || n == 1) return true;
        if (m == 0 || n == 0) return false;

        if (m < n) return Coprime(m, n % m);
        return Coprime(m % n, n);
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class A
    {
        public void Run()
        {
            int n = int.Parse(Console.ReadLine());
            //int[] m = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            //string str = Console.ReadLine();

            ulong rez = 0;
            ulong off = 0;

            for (int k = 1; k <= n; k++)
            {
                for (int i = 1; i <= 10000; i++)
                {
                    double j = k * k - i * i;
                    double sqr = Math.Sqrt(j);

                    if ((j > 0) && (sqr * sqr == j))
                    {
                        rez+=1;
                        if (sqr != i)
                        {
                            off += 1;
                        }
                    }
                    else
                        if (j < 0)
                        {
                            break;
                        }
                }
            }
            ulong rez2 = rez - off / 2;

            Console.Write(rez2);
        }
    }
    class B
    {
        public void Run()
        {
            int[] str = Console.ReadLine().Split(':').Select(a => int.Parse(a)).ToArray();
            int[] str2 = Console.ReadLine().Split(':').Select(a => int.Parse(a)).ToArray();

            DateTime d1 = new DateTime(str[0], str[1], str[2]);
            DateTime d2 = new DateTime(str2[0], str2[1], str2[2]);

            TimeSpan ts = d2 - d1;

            Console.WriteLine(Math.Abs(ts.Days));
        }
    }

    class Programm
    {
        static void Main(string[] args)
        {
            A a = new A();
            a.Run();
        }
    }
}