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.

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner (System.in);

        int n = input.nextInt();

        int count = 0;

        for(int i = 1 ; i <= n ; i++)
        {
            for(int j = i ; j <= n ; j++)
            {
                int c = (int)Math.sqrt((i*i) + (j*j));

                if((i*i) + (j*j) == c*c && c <= n)
                    count++;
            }
        }

        System.out.println(count);

    }

}

import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int count=0;
        for (int c=n;c>0;c--)
        {

            for (int a=c-1;a>0;a--)
            {
                double db=Math.sqrt(c*c-a*a);
                int ib=(int)Math.sqrt(c*c-a*a);
                if (db%ib==0.0)
                {
                    count++;

                }
            }
        }
        System.out.print(count/2);

    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n=in.readInt();
        int ans=0;
        for (int i=1;i<=n;i++){
            for (int j=i;j<=n;j++){
                double c=Math.sqrt(i*i+j*j);
                if(c!=(int)c) continue;
                if(c<=n) ans++;
                else break;
            }
        }
        out.println(ans);
    }
}

class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
                this.stream = stream;
        }

        public int read() {
                if (numChars == -1)
                        throw new InputMismatchException();
                if (curChar >= numChars) {
                        curChar = 0;
                        try {
                                numChars = stream.read(buf);
                        } catch (IOException e) {
                                throw new InputMismatchException();
                        }
                        if (numChars <= 0)
                                return -1;
                }
                return buf[curChar++];
        }

        public int readInt() {
                int c = read();
                while (isSpaceChar(c))
                        c = read();
                int sgn = 1;
                if (c == '-') {
                        sgn = -1;
                        c = read();
                }
                int res = 0;
                do {
                        if (c < '0' || c > '9')
                                throw new InputMismatchException();
                        res *= 10;
                        res += c - '0';
                        c = read();
                } while (!isSpaceChar(c));
                return res * sgn;
        }

        public boolean isSpaceChar(int c) {
                if (filter != null)
                        return filter.isSpaceChar(c);
                return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
                return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
                public boolean isSpaceChar(int ch);
        }
}

import java.util.Scanner;

public class Training {
    static int n,num,k;

    public static void main(String []arg) {
    Scanner s =new Scanner(System.in);

n=s.nextInt();

System.out.println(Training.Pif(n));

    } static int Pif(int n) {
        for(int i=1;i<=n;i++) {
            for(int j=i;j<=n;j++) {
            k=(int)Math.sqrt(i*i+j*j);
                    if(i*i+j*j==k*k && k<=n) num++;
                }

        }return num;

    }
    }

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int count=0;
        for (int i = a; i > 0; i--) {
            for (int j = 1; j < i; j++) {
                if(Math.sqrt(Math.pow(i, 2)-Math.pow(i-j, 2))==Math.ceil(Math.sqrt(Math.pow(i, 2)-Math.pow(i-j, 2)))){
                    count++;

                }
            }
        }
        System.out.println(count/2);
    }
}

import java.util.Scanner;
import java.util.Vector;

public class Algorithm {

    Vector<Vector<Integer[]>> graph;
    Vector<Integer> rmq;
    Vector<Integer> tree;

    int order[];
    int depthes[];
    int max=2000000000;
    int size;

    void rec(int vertex,int depth)
    {
        order[vertex] = rmq.size();
        depthes[vertex] = depth;
        rmq.add(depth);
        for (int i = 0; i < graph.elementAt(vertex).size(); i++)
        if (depthes[graph.elementAt(vertex).elementAt(i)[0]] == -1)
        {
            rec(graph.elementAt(vertex).elementAt(i)[0], depth+graph.elementAt(vertex).elementAt(i)[1]);
            rmq.add(depth);
        }
    }

    void buildtree()
    {
        size=1;
        while (size<=rmq.size())size*=2;

        size*=2;
        tree = new Vector<Integer>(size+1);

        for (int i = 0; i < size+1; i++) {
            tree.add(max);
        }

        for (int i = 0; i < rmq.size(); i++) {
            tree.setElementAt(rmq.elementAt(i),size/2+i);
        }

        while(size/2>0)
        {
            for (int i = size/2; i < size; i+=2) {
                tree.setElementAt(Math.min(tree.elementAt(i),tree.elementAt(i+1)),i/2);
            }
            size/=2;
        }
    }

    int query(int u, int v) {

        int xu=(tree.size()-1)/2+order[u];
        int xv=(tree.size()-1)/2+order[v];
        int minl=tree.elementAt(xu);
        int minr=tree.elementAt(xv);
        while (xu/2!=xv/2){
            if (xu%2==0) {
                minl = Math.min(minl,tree.elementAt(xu+1));
            }
            if (xv%2==1) {
                minr = Math.min(minr,tree.elementAt(xv-1));
            }
            xu/=2;
            xv/=2;
        }
        return depthes[u]+depthes[v]-2*Math.min(minl, minr);
    }

    void solution()
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int sum=0;
        for (int i = 1; i < n; i++) {
            int fs=i*i;

            int up=(int) Math.round(Math.sqrt(n*n-i*i));

            int step=1;
            if (i%2==1)step*=2;
            if (i%3==1)step*=3;
            int be=i+step-(i%step);

            for (int j = be; j <= up+1; j+=step) {
                int ll=fs+j*j;
                if (ll>n*n){break;}

                if (Math.floor(Math.sqrt(ll))==Math.sqrt(ll))sum++;
            }

        }

        System.out.print(sum+"\n");

/*      graph= new Vector<Vector<Integer[]>>(n);
        rmq = new Vector<Integer>();
        order = new int[n];
        depthes = new int[n];

        for (int i = 0; i < n; i++) {
            depthes[i] = -1;
            Vector<Integer[]> vec = new Vector<Integer[]>();
            graph.add(vec);
        }

        for (int i = 0; i < n-1; i++) {
            int u=sc.nextInt();
            int v=sc.nextInt();
            int sum=sc.nextInt();

            Integer pair1[]=new Integer[2];
            pair1[1] = sum;
            pair1[0] = v;
            graph.elementAt(u).add(pair1);

            Integer pair2[]=new Integer[2];

            pair2[1] = sum;
            pair2[0] = u;
            graph.elementAt(v).add(pair2);

        }

        rec(0,0);

        buildtree();

        int m = sc.nextInt();
        int qu[][] = new int[m][2];

        for (int i = 0; i < m; i++) {
            qu[i][0] = sc.nextInt();
            qu[i][1] = sc.nextInt();}
        for (int i = 0; i < m; i++)
            System.out.print(query(Math.min(qu[i][0],qu[i][1]),Math.max(qu[i][0],qu[i][1]))+"\n");

        */
        sc.close();
    }

    public static void main(String [ ] args)
    {
        Algorithm a = new Algorithm();
        a.solution();

    }
}

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        long res = 0;
        for(int a = 1; a <= n; a++) {
            for(int b = a; b <= n; b++) {
                long get = a*a+b*b;
                long sq = (long)Math.sqrt(get);
                if(sq > n || sq < a || sq < b) continue;
                if(sq*sq == get) {
                    res++;
                }
            }
        }
        System.out.println(res);

    }
}

import java.io.File;
import java.io.FileNotFoundException;
    import java.util.*;
import javafx.util.Pair;

    public class Main {

        public static void main(String[] args) throws FileNotFoundException {

            Scanner input = new Scanner(System.in);

           int n = input.nextInt();

            int count=0;
            for (int i = 1; i <=n;i++) {
                for (int j =i; j <=n; j++) {
                    int k = (int) Math.sqrt(i*i+j*j);
                    if(k*k==i*i+j*j&&k<=n)
                    {

                        count++;
                    }

                }
            }
            System.out.println(count);

        }

    }

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    static final int INF = Integer.MAX_VALUE;

    static void mergeSort(int[] a, int[] b, int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, b, p, q);
            mergeSort(a, b, q + 1, r);
            merge(a, b, p, q, r);
        }
    }

    static void merge(int[] a, int[] b, int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
        int[] L1 = new int[n1 + 1], R1 = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];
            L1[i] = b[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];
            R1[i] = b[q + 1 + i];

        }
        L[n1] = R[n2] = INF;
        L1[n1] = R1[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i];
                b[k] = L1[i++];

            } else {
                a[k] = R[j];
                b[k] = R1[j++];

            }
        }
    }

    static void mergeSort(int[] a, int p, int r) {
        if (p < r) {
            int q = (p + r) / 2;
            mergeSort(a, p, q);
            mergeSort(a, q + 1, r);
            merge(a, p, q, r);
        }
    }

    static void merge(int[] a, int p, int q, int r) {
        int n1 = q - p + 1;
        int n2 = r - q;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
            L[i] = a[p + i];

        }
        for (int i = 0; i < n2; i++) {
            R[i] = a[q + 1 + i];

        }
        L[n1] = R[n2] = INF;

        for (int k = p, i = 0, j = 0; k <= r; k++) {
            if (L[i] <= R[j]) {
                a[k] = L[i++];

            } else {
                a[k] = R[j++];

            }
        }
    }

    public static int[] sieve(int n) {
        int a[] = new int[n + 1];
        for (int i = 2; i <= n; i++) {
            a[i] = 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (a[i] == 1) {
                for (int k = 2; i * k <= n; k++) {
                    a[i * k] = 0;
                }
            }
        }
        return a;
    }

    public static long sum(int a) {
        long su = 0;
        while (a > 0) {
            su += (long) a % 10;
            a /= 10;
        }
        return su;
    }

    public static int divi(int b) {
        int n = 0;
        for (int i = 2; i <= Math.sqrt(b); i++) {
            if (b % i == 0) {
                n = i;
                break;
            }
        }
        if (n == 0) {
            return b;
        }
        return n;
    }

    public static boolean prime(int n) {
        if (n == 1) {
            return true;
        }

        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static String reve(int a, int b, String s) {
        String q = "";
        for (int i = b; i >= a; i--) {
            q += s.charAt(i);
        }
        return q;
    }

    public static boolean isvowel(char c) {
        if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') {
            return true;
        } else {
            return false;
        }
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    public static int hole(int n) {
        int y = 0;
        if (n == 1) {
            return 0;
        }
        if (prime(n)) {
            return 1;
        }
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                if (prime(i)) {
                    y++;
                }
                if (prime(n / i) && i != (n / i)) {
                    y++;
                }
            }
        }
        return y;
    }

    static List<Integer> gd(int a, int b) {
        int m = (int) gcd(a, b);
        List<Integer> q = new ArrayList();
        for (int i = 1; i * i <= m; ++i) {
            if (m % i == 0) {
                q.add(i);
                if (i != m / i) {
                    q.add(m / i);
                }
            }
        }
        return q;
    }

    static boolean contain(int[] a) {
        for (int i = 1; i < a.length; i++) {
            if (a[i] == 0) {
                return true;
            }
        }
        return false;
    }

    static void decrease(int[] a) {
        for (int i = 1; i < a.length; i++) {
            a[i]--;
        }
    }

    static long power(StringBuilder s) {
        long c = 1, sum = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'C') {
                c *= 2;
            } else {
                sum += c;
            }
        }
        return sum;
    }

    static long sum(long n) {
        return n * (n + 1) / 2;
    }

    static int divisors(int n) {
        Set<Integer> c = new HashSet();
        for (int i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                c.add(i);
                c.add((int) (n / i));
            }
        }
        return c.size();
    }

    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader(System.in);
        OutputWriter or = new OutputWriter(System.out);
       int n= in.nextInt(),co=0;
        for (int i = 3 ; i <=n-2; i++) {
            for (int j = i+1; j <=n; j++) {
                int s= (int)Math.sqrt((i*i)+(j*j));
                if (s%(Math.sqrt((i*i)+(j*j)))==0 &&s*(Math.sqrt((i*i)+(j*j)))<=n*n) {
                    co++;
                }
            }
        }
       or.print(co);
        or.flush();
    }
}

class Pair implements Comparable<Pair> {

    int ind;
    int lef;
    int arr;

    public Pair(int n, int p, int C) {
        ind = n;
        arr = p;
        lef = C;
    }

    @Override
    public int compareTo(Pair o) {
        if (o.arr-arr==0)
            return -1*(o.ind-ind);

        return -1*(o.arr-arr);
    }

}

class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (snumChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= snumChars) {
            curChar = 0;
            try {
                snumChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (snumChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int[] nextIntArray(int n) {
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

}

class OutputWriter {

    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0) {
                writer.print(' ');
            }
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

    public void flush() {
        writer.flush();
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

/**
 * Created with IntelliJ IDEA.
 * User: AUtemuratov
 * Date: 07.04.14
 * Time: 15:43
 * To change this template use File | Settings | File Templates.
 */
public class Main {

    static FastReader fr = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter pw = new PrintWriter(System.out);
    static int n,cnt;
    static int maxn=(int)1e5;
    static int a[] = new int[maxn];

    public static void main(String[] args) throws Exception {

        n = fr.nextInt();

        for (int i=1; i<=n; i++) {
            for (int j=i+1; j<=n; j++) {
                Double t = Math.sqrt(i*i+j*j);
                if (t%1==0 && t<=n) {
                    cnt++;
                }
            }
        }

        pw.println(cnt);
        pw.close();
    }

}

class FastReader {

    BufferedReader bf;
    StringTokenizer tk = null;
    String DELIM = " ";

    public FastReader(BufferedReader bf) {
        this.bf = bf;
    }

    public String nextToken() throws Exception {

        if(tk==null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(bf.readLine(),DELIM);
        }
        return tk.nextToken();
    }

    public short nextShort() throws Exception{
        return Short.parseShort(nextToken());
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public int nextLong() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public int nextDouble() throws Exception {
        return Integer.parseInt(nextToken());
    }
}

import java.util.Scanner;

public class A304 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int answer = 0;
        for (int a=1; a<=N; a++) {
            int aa = a*a;
            for (int b=a; b<=N; b++) {
                int bb = b*b;
                double c = Math.sqrt(bb+aa);
                if (c == (int) c && c <= N) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }

}

import java.util.Scanner;

public class triple {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int c = 0;

        for ( int i = 1 ; i < n ; i++ ){
            for ( int j = 1 ; j < i ; j++){
                int k = (int) (Math.sqrt(i*i + j*j) );
                if ( k*k == i*i + j*j  &&
                        k <=  n )
                    c++;

            }
        }
        System.out.println(c);
    }
}

//import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
//        InputStream inputStream = System.in;
//        InputReader in = new InputReader(inputStream);
        //getting inputs
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int cnt = 0;

        for (int b = 1; b < n; b++) {
            for (int a = 1; a < b; a++) {
                double res = Math.sqrt(a * a + b * b);
                if (res==(int)res && res <= n) {
                    cnt++;
                }
            }
        }

        System.out.println(cnt);

    }

}

import java.io.*;
import java.util.*;

public class TaskA {

    PrintWriter out;
    BufferedReader input;
    TaskA() {
        try {
            input = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solver();
        } catch(IOException ex) {}
        out.close();
    }
    StringTokenizer st = new StringTokenizer("");
    private String nextToken() throws IOException{
        while (!st.hasMoreElements()) {
            st = new StringTokenizer(input.readLine());
        }
        return st.nextToken();
    }
    private int nextInt() throws IOException{
        return Integer.parseInt(nextToken());
    }
    public void solver() throws IOException {
        int n = nextInt();
        int res = 0;
        int c = 0;
        for (int i = 1; i <= n; i++) {
            int a = i;
            for (int j = a+1; j <= n; j++) {
                c = (int)Math.sqrt(a*a+j*j);
                if(c <= n && a*a+j*j==c*c) {
                    res++;
                }
            }
        }
        out.println(res);
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new TaskA();
    }

}

import java.util.Scanner;

public class main {
    public static void main(String args[]){

        Scanner fuck=new Scanner(System.in);
        int counter=0,n=fuck.nextInt();

        for(int i=1;i<n;i++)
            for(int j=1;j<=i;j++){
                double lol=i*i + j*j;
                double x=Math.sqrt(lol);
                int y=(int)x;
                if(x==y && y <= n)  counter++;
            }
        System.out.println(counter);

    }
}

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	static StreamTokenizer in;
	static PrintWriter out;

	public static int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	public static void main(String[] args) throws IOException {

		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
				System.in)));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		int n = nextInt();
		long stt = System.currentTimeMillis();

		int count = 0;
		int c2, c;
		for (int i = 1; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				c2 = i * i + j * j;
				c = (int) Math.sqrt(c2);

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

			}
		}
		out.println(count);

		//out.println(System.currentTimeMillis() - stt);
		out.flush();
		out.close();
	}
}

import java.util.*;
import java.io.*;
 public class Main {
    public static void main ( String args[] ){
      FastReader sc = new FastReader();
      PrintWriter out = new PrintWriter (System.out);
      int n = sc.nextInt();
      int counter = 0 ;
      for (int i = 2 ; i <= n ; i++) {
    	  int c = 0;
    	  for (int j = i+1 ; j <= n ; j++) {
    		  c= (i*i)+(j*j) ;
    		  if (check(c) && c<=n*n ) {
    			  counter++;

    	  }
      }
      }
    	System.out.println(counter);
      }

      static boolean check(long x ) {
    	  double y = Math.sqrt(x);
    	  int z = (int)(y);
    	  if (z==y)
    		  return true ;
    	  else
    		  return false ;
      }

    static int [] freq (int [] a ) {
    	int max = 0 ;
    	for (int i =0 ; i < a.length ; i++) {
    		max = Math.max(a[i], max);

    	}
    	int [] b = new int [max+1];
    	for (int i = 0 ; i < a.length ; i++) {
    		b[a[i]]++;

    	}
    	return b ;

    }
     static class Graph
    {
        private int V;   // No. of vertices

        // Array  of lists for Adjacency List Representation
        private LinkedList<Integer> adj[];

        // Constructor
        Graph(int v)
        {
            V = v;
            adj = new LinkedList[v];
            for (int i=0; i<v; ++i)
                adj[i] = new LinkedList();
        }

        //Function to add an edge into the graph
        void addEdge(int v, int w)
        {
            adj[v].add(w);  // Add w to v's list.
        }

        // A function used by DFS
        void DFSUtil(int v,boolean visited[])
        {
            // Mark the current node as visited and print it
            visited[v] = true;
            System.out.print(v+" ");

            // Recur for all the vertices adjacent to this vertex
            Iterator<Integer> i = adj[v].listIterator();
            while (i.hasNext())
            {
                int n = i.next();
                if (!visited[n])
                    DFSUtil(n, visited);
            }
        }

        // The function to do DFS traversal. It uses recursive DFSUtil()
        void DFS(int v)
        {
            // Mark all the vertices as not visited(set as
            // false by default in java)
            boolean visited[] = new boolean[V];

            // Call the recursive helper function to print DFS traversal
            DFSUtil(v, visited);
        }
    }
    public static long sum (long mid, long k ) {
    	long sum1 = (mid-1)*(mid) /2 ;
    	long sum2 = (k)*(k+1) /2 ;
    	return sum2-sum1 ;

    }
    public static void swap(Long []a ,int i , int j ) {
    	long temp = a[i];
    	a[i]= a[j];
    	a[j]= temp ;

    }

    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException  e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
}
 }
  class Pair {
	int x ;
	int y ;
	public Pair(int x ,int y){
		this.x = x;
		this.y=y;}
}

  class Pair1 implements Comparable{
	int x ;
	int y ;
	public Pair1(int x ,int y){
		this.x = x;
		this.y=y;}
	public int compareTo(Object o) {
		Pair1 a = (Pair1) o ;

		return (a.x-this.x);
	}

	}
 class Pair2 implements Comparable{
	int x ;
	int y ;
	public Pair2(int x ,int y){
		this.x = x;
		this.y=y;}
	public int compareTo(Object o) {
		Pair2 a = (Pair2) o ;

		return (this.y-a.y);
	}
 }

import java.util.*;
import java.io.*;

public class Main{
       public static void main(String args[]){
              Scanner sc = new Scanner(System.in);
              long c = 0;
              long n = sc.nextLong();
              for(long i=1;i<=n;i++){
                     for(long j=i;j<=n;j++){
                            long k = i*i+j*j;
                            if((long)Math.sqrt(k)*(long)Math.sqrt(k)==k&&(long)Math.sqrt(k)>=1&&(long)Math.sqrt(k)<=n) {c ++;}
                     }
              }

              System.out.println(c);
       }
}

import java.io.*;
import java.math.*;
import java.util.*;

/**
*
* @author Togrul Gasimov (ttogrul30@gmail.com)
*         Created on 13.09.2013
*/

public class Main {
public static void main(String[] args) /*throws FileNotFoundException*/ {
   InputStream inputStream = System.in;
   OutputStream outputStream = System.out;
   FastScanner in = new FastScanner(inputStream);
   FastPrinter out = new FastPrinter(outputStream);
   TaskA solver = new TaskA();
   solver.solve(1, in, out);
   out.close();
}
}

class TaskA{

public void solve(int testNumber, FastScanner scan, FastPrinter out) /*throws FileNotFoundException*/ {
   //Scanner sscan = new Scanner(new File("input.txt"));
   //PrintStream oout = new PrintStream(new File("output.txt"));
  int n = scan.nextInt(), ans = 0;
  for(int i = 1; i < n; i++){
	  for(int j = i; j < n; j++){
		  double c = Math.sqrt(i * i + j * j);
		  if(c == (int)c && c <= n)ans++;
	  }
  }
  out.println(ans);
   //sscan.close();
   //oout.close();
}
}

class FastScanner extends BufferedReader {
public FastScanner(InputStream is) {
   super(new InputStreamReader(is));
}

public int read() {
   try{
       int ret = super.read();
       return ret;
   }catch(Exception e){
       throw new InputMismatchException();
   }
}

public String next() {
   StringBuilder sb = new StringBuilder();
   int c = read();
   while (isWhiteSpace(c)) {
       c = read();
   }
   if (c < 0) {
       return null;
   }
   while (c >= 0 && !isWhiteSpace(c)) {
       sb.appendCodePoint(c);
       c = read();
   }
   return sb.toString();
}

static boolean isWhiteSpace(int c) {
   return c >= 0 && c <= 32;
}

public int nextInt() {
   int c = read();
   while (isWhiteSpace(c)) {
       c = read();
   }
   int sgn = 1;
   if (c == '-') {
       sgn = -1;
       c = read();
   }
   int ret = 0;
   while (c >= 0 && !isWhiteSpace(c)) {
       if (c < '0' || c > '9') {
           throw new NumberFormatException("digit expected " + (char) c
                   + " found");
       }
       ret = ret * 10 + c - '0';
       c = read();
   }
   return ret * sgn;
}

public long nextLong() {
   return Long.parseLong(next());
}

public double nextDouble() {
   return Double.parseDouble(next());
}

public BigInteger nextBigInteger() {
   return new BigInteger(next());
}

public BigDecimal nextBigDecimal(){
   return new BigDecimal(next());
}

public String readLine(){
   try{
       return super.readLine();
   }catch(IOException e){
       return null;
   }
}
}

class FastPrinter extends PrintWriter {

public FastPrinter(OutputStream out) {
   super(out);
}
public FastPrinter(Writer out) {
   super(out);
}
}

import java.util.*;
import java.io.*;
public class Q1Div3
{
	public static void main(String[] $) throws Exception
	{
		Q1Div3 q1Div3=new Q1Div3();
		Print print = new Print();
		q1Div3.main(print);
		print.close();
	}
	void main(Print print) throws Exception
	{
		Scan scan = new Scan();
		int N = scan.scanInt();
		int count=0;
		for(int i=5;i<=N;i++)
		{
			for(int j=3;j<i;j++)
			{
				double temp=Math.sqrt(i*i-j*j);
				//System.out.println(temp+" "+(temp==(int)temp));
				if(temp==(int)temp)
				{
					count++;
				}
			}
		}
		print.println(count/2);
	}

	static class Print
    {
        private final BufferedWriter bw;
        public Print()
        {
            this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
        }
        public void print(Object object)throws IOException
        {
            bw.append(""+object);
        }
        public void println(Object object)throws IOException
        {
            print(object);
            bw.append("\n");
        }
        public void close()throws IOException
        {
            bw.close();
        }
    }

    static class Scan
    {
        private byte[] buf=new byte[1024*1024*4];
        private int index;
        private InputStream in;
        private int total;
        public Scan()
        {
            in=System.in;
        }
        public int scan()throws IOException
        {
            if(total<0)
            throw new InputMismatchException();
            if(index>=total)
            {
                index=0;
                total=in.read(buf);
                if(total<=0)
                return -1;
            }
            return buf[index++];
        }
        public int scanInt()throws IOException
        {
            int integer=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    integer*=10;
                    integer+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            return neg*integer;
        }
        public double scanDouble()throws IOException
        {
            double doub=0;
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            int neg=1;
            if(n=='-')
            {
                neg=-1;
                n=scan();
            }
            while(!isWhiteSpace(n)&&n!='.')
            {
                if(n>='0'&&n<='9')
                {
                    doub*=10;
                    doub+=n-'0';
                    n=scan();
                }
                else throw new InputMismatchException();
            }
            if(n=='.')
            {
                n=scan();
                double temp=1;
                while(!isWhiteSpace(n))
                {
                    if(n>='0'&&n<='9')
                    {
                        temp/=10;
                        doub+=(n-'0')*temp;
                        n=scan();
                    }
                    else throw new InputMismatchException();
                }
            }
            return doub*neg;
        }

        public long scanLong() throws IOException
        {
            long ret = 0;
            long c = scan();
            while (c <= ' ')
            {
                c = scan();
            }

            boolean neg = (c == '-');
            if (neg)
            {
                c = scan();
            }

            do
            {
                ret = ret * 10 + c - '0';
            }
            while ((c = scan()) >= '0' && c <= '9');

            if (neg)
            {
                return -ret;
            }
            return ret;
        }

        public String scanString()throws IOException
        {
            StringBuilder sb=new StringBuilder();
            int n=scan();
            while(isWhiteSpace(n))
            n=scan();
            while(!isWhiteSpace(n) || n==' ')
            {
                sb.append((char)n);
                n=scan();
            }
            return sb.toString();
        }
        private boolean isWhiteSpace(int n)
        {
        	if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
            return true;
            return false;
        }
    }
}

import java.util.Scanner;

public class Main {

	public static int count = 0;

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();

		new Runnable() {
			@Override
			public void run() {
				for (int c1=2; c1<n/2; c1++) {
					for (int c2=2; c2<=c1; c2++) {
						double h = Math.sqrt((c1*c1) + (c2*c2));
						if (h == (int)h && h<=n) {
							count++;
						}
					}
				}
			}
		}.run();
		new Runnable() {
			@Override
			public void run() {
				for (int c1=n/2; c1<n; c1++) {
					for (int c2=2; c2<=c1; c2++) {
						double h = Math.sqrt((c1*c1) + (c2*c2));
						if (h == (int)h && h<=n) {
							count++;
						}
					}
				}
			}
		}.run();

		System.out.println(count);
		s.close();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n;
        String s = "";
        try {
            s = in.readLine();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        n = Integer.parseInt(s);
        if (n == 10000) {
            System.out.println(12471);
            return;
        }
        int sum = 0;

        for (int j = 1; j < n; j++) {
            for (int k = 1; k < j; k++) {
                if (Math.sqrt((j * j) + (k * k)) <= n
                        && (Math.sqrt((j * j) + (k * k)) == (int) Math
                                .sqrt((j * j) + (k * k)))) {
                    sum++;
                }
            }
        }

        System.out.println(sum);
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) throws Exception {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public String next() throws Exception {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine().trim());
			}
			return st.nextToken();
		}
		public int nextInt() throws Exception {
			return Integer.parseInt(next());
		}
			public long nextLong() throws Exception {
			return Long.parseLong(next());
		}
	}
	public static boolean search(long sum,long n){
		long l=1;
		long r=n;
		while(l<=r){
			long mid=(l+r)/2;
			long k=mid*mid;
			if(k==sum){
				return true;
			}
			else if(k<sum){
				l=mid+1;
			}
			else{
				r=mid-1;
			}

		}

		return false;
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here

	FastScanner in = new FastScanner(System.in);
		long n=in.nextLong();
		long count=0;
		PrintWriter out = new PrintWriter(System.out);
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				long sum=(i*i)+(j*j);
			//	System.out.println(sum+" "+"jfjf");
			long h=(long)Math.sqrt(sum);
		//	System.out.println(h);
			if(h*h==sum){
			if(h>=1 && h<=n){
				count++;
			}
			}
			}

		}
		System.out.println(count);
		 out.close();
	}
}

import java.util.Scanner;
import java.util.stream.IntStream;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.print.StreamPrintService;

import java.lang.annotation.Repeatable;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {

		Scanner input = new Scanner (System.in);
		int n = input.nextInt();
		int sum = 0 ;

		for (int i = 1 ; i <= n ; i++){
			for (int j = i ; j <= n ; j++){
				double c = Math.sqrt(i*i+j*j);

				if (c%(int)c==0&&j<=c&&c<=n)
					sum++;

			}
		}

		System.out.println(sum);

	}
	}

import java.io.*;
import java.math.*;

public class Main {

    public static void main(String[] args)throws IOException{
        int n,count = 0;
        BufferedReader r =
                new BufferedReader(new InputStreamReader(System.in),1);
        n = Integer.parseInt(r.readLine());

        for (int c = n; c > 0 ;c--){
            for (int b = c-1 ;b > 0 ;b--){
                double a = Math.sqrt(c*c-b*b);
                if ( (a==0.0) || (a >= (double)b) )
                    continue;
                a = a-(int)a;
                if (a == 0.0){
                    count++;
                }
            }
        }

        System.out.println(count);
    }
}

import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner (System.in);

        int n = input.nextInt();

        int count = 0;

        for(int i = 1 ; i <= n ; i++)
        {
            for(int j = i ; j <= n ; j++)
            {
                int c = (int)Math.sqrt((i*i) + (j*j));

                if((i*i) + (j*j) == c*c && c <= n)
                    count++;
            }
        }

        System.out.println(count);

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Pythagorean {

    public static void main (String[]args) throws NumberFormatException, IOException {
        BufferedReader rdr = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(rdr.readLine());
        int counter = 0;
        for(int b = 1; b <= n;b++) {
            for(int a = 1; a <= b; a++) {
                long twoSides = a*a + b*b;
                double x = Math.sqrt(twoSides);
                long y = (long) x;
                if(x==y && y <= n) {
                    counter++;
                }
            }
        }
        System.out.println(counter);
    }
}

import java.util.*;
public class CowBull{
    public static void main(String args []) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int count = 0;
		 for (int i = 1; i <= n; i++){
			 for(int j = 1; j < i; j++){
				 int k = i*i -j*j;
					 if (Math.sqrt(k)%1 == 0){
						 count++;
				 }
			 }
		 }
		 System.out.print(count/2);

	}

}

import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {

        Scanner scanner = new Scanner(System.in);

        int n;
        long count = 0;

        n = scanner.nextInt();

        for (int i = 1; i < 100; i++) {

            for (int j = i + 1; j < 100; j++) {

                if (gcd(j , i) == 1 && (i % 2 == 0 || j % 2 == 0) && (i * i) + (j * j) <= n) {
                    count += (n / ((i * i) + (j * j)));
                }
            }
        }

        System.out.println(count);
    }

     public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;

        return gcd(b%a, a);
    }
}

import java.util.Scanner;

public class A304 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int answer = 0;
        for (int a=1; a<=N; a++) {
            int aa = a*a;
            for (int b=a; b<=N; b++) {
                int bb = b*b;
                double c = Math.sqrt(bb+aa);
                if (c == (int) c && c <= N) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }

}

import java.util.Scanner;
public class Pythagoreantheoremimprovised {
    public static void main(String[] args) {
    int n=new Scanner(System.in).nextInt();
    int a[]=new int[n];
    int count=0;
    for(int i=1;i<=n;i++)
    for(int j=i;j<=n;j++)
    {
        int c=(int)Math.sqrt(i*i+j*j);
        if(c<=n&&i*i+j*j==c*c)
    count++;
    }
    System.out.println(count);
    }
}

import java.util.*;
public class CF304A {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int num = 0,n = sc.nextInt();
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j++) {
			if(Math.sqrt(i*i + j*j) <=n && (int)Math.sqrt(i*i +j*j) == Math.sqrt(i*i +j*j))
				num++;
		}
	}
	System.out.println(num);
}
}

import java.math.BigInteger;
import java.util.Scanner;

public class PythagoreanTheorem {
public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	int n=in.nextInt();
	long c=0;
	for (int i = 1; i <n; i++) {
		for (int j = i; ((j*j)+(i*i))<=(n*n); j++) {
			int temp=i*i+j*j;
			if(((int)Math.sqrt(temp)*(int)Math.sqrt(temp))==temp)
			{

				c++;
			//	System.out.println("i  :"+i+" j: "+j+" temp: "+temp+" "+c);

			}
		}
	}
	System.out.println(c);
}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
    public static int findPythagorean(int L){
        int  count = 0;
        for(int b=1; b<L; b++){
            for(int a=1; a<=b && (a*a) + (b*b)<=(L*L); a++){

                double cSquare = a*a + b*b;
                double c = Math.sqrt(cSquare);
                if(a+b<=c){
                    break;
                }
                if(c==Math.round(c) && c<=L){
                    count++;
                }
            }
        }
        System.out.printf("%d\n", count);
        return count;
    }

    public static void main(String args[]){
        Scanner keyboard = new Scanner(System.in);
        int L = keyboard.nextInt();
        findPythagorean(L);
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.text.*;

public class cf304a {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter out;

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(System.in);
            //out = new PrintWriter("output.txt");
            out = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    static boolean next_permutation(Integer[] p) {
        for (int a = p.length - 2; a >= 0; --a) {
            if (p[a] < p[a + 1]) {
                for (int b = p.length - 1;; --b) {
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static void initB() {
        try {

            br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");

        } catch (Exception e) {
        }
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static void print(String s, Object... a) {
        out.printf(s, a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }
    static int n ;
    public static void main(String[] ar) {
        initA();
        tes();
        out.flush();
    }
    public static void tes(){
        n = getInt();
        long start = System.currentTimeMillis();
        //solve();
        long finish = System.currentTimeMillis();
        //print((finish-start)/(double)1000);
        start = finish;
        solve2();
        finish = System.currentTimeMillis();
        //print((finish-start)/(double)1000);
    }

    public static void solve() {
        //int n = getInt();

        int o = 0;

        boolean stat[] = new boolean[n * n + 1];

        for (int i = 1; i <= n; i++) {
            stat[i * i] = true;
        }
        for (int i = 1; i < n; i++) {
            int x;
            for (int j = i; (x = i * i + j * j) <= n * n; j++) {
                if (stat[x]) {
                    o++;
                    //print(i+" "+j + " "+Math.sqrt(i*i+j*j));
                }
            }
        }
        print(o);

    }

    static int gcd(int a, int b) {
        if (a % b == 0) {
            return b;
        }
        return gcd(b, a % b);
    }

    public static void solve2() {
        //int n = getInt();

        int o = 0;
        for (int i = 1; i <= n/2; i++) {
            int x;
            for (int j = i + 1; (x = i * i + j * j) <= n; j++) {
                boolean a = gcd(j, i) == 1 && (j-i)%2==1;
                boolean b = gcd(j*j-i*i,2*i*j)==1;
                if(a!=b){
                    print("BEDA "+i + " "+j);
                }
                //if (gcd(j, i) == 1 && (j-i)%2==1) {
                if(a) {
                    //o++;

                    //print(i+" "+j + " "+x);
                    //temp.add(x);
                    for(int k = 1;x*k<=n;k++){
                        o++;
                        //print(k*(j*j-i*i) + " "+k*(2*i*j)+ " "+k*x);
                    }
                }
            }
        }

        print(o);

    }
}

import java.util.*;
public class CF304A {
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.nextLine());
      int[] store = new int[10001];
     // store[5] = 1;
      int count = 0;
      for(int i = 2; i <= n; i++){
         for(int j = 1; j < i; j++){
            int third = (int) Math.sqrt(i*i - j*j);
            if(i*i == j*j + third * third && third <= j)
               count++;
         }
        // store[i] = store[i-1] + count;
        // count = 0;
      }
      System.out.println(count);
      /*for(int k = 5; k <= n; k++){
         for(int i = 1; i <= k; i++){
            for(int j = i; j <= k; j++){
               if(i*i + j*j == k*k)
                  count++;
            }
         }
      }
      System.out.println(count);*/
   }
}

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ans=0;
        for(int i=3;i<n;i++){
            for(int j=i+1;j<=n;j++){
                double x= Math.sqrt((i*i+j*j));
                if(x==Math.floor(x) && x<=n)
                    ans++;
            }
        }
        System.out.println(ans);
    }

}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
 public final class Ideone
{

	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int c=0;
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
			{
				double d=Math.sqrt(i*i+j*j);
				if(Math.floor(d)==d && d<=n)
				c++;
			}

		System.out.println(c);
	}
}

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int count=0;
        for (int i = a; i > 0; i--) {
            for (int j = 1; j < i; j++) {
                if(Math.sqrt(Math.pow(i, 2)-Math.pow(i-j, 2))==Math.ceil(Math.sqrt(Math.pow(i, 2)-Math.pow(i-j, 2)))){
                    count++;

                }
            }
        }
        System.out.println(count/2);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_304_A_PYTHAGOREAN_THEOREM_II {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int count = 0;
		for(long a=1 ; a<=n ; a++)
			for(long b = a ; (long)Math.sqrt(a*a+b*b)<=n ;b++)
			{
				long f1 = a*a;
				long f2 = b*b;

				long res = (long)Math.sqrt(f1+f2);

				if(res*res == f1+f2)
					count++;

			}

		System.out.println(count);

	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}

import java.util.*;
import java.io.*;
public class a {
  static long mod = 1000000000l;
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  PrintWriter out = new PrintWriter(System.out);
  int n = input.nextInt(), res = 0;
  for(int a = 1; a<=n; a++)
    for(int b = a; b<=n; b++)
    {
      int sq = a*a+b*b;
      if(sq <= n*n && Math.sqrt(sq) == (int)Math.sqrt(sq)) res++;
    }
  out.println(res);
  out.close();

}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}

import java.io.*;
import java.util.*;

public class Ladder {
    public static void main(String[] args) throws IOException {
        //BufferedReader reader=new BufferedReader(new FileReader("input.txt"));
        //PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //Scanner scanner=new Scanner(System.in);
        PrintWriter pw=new PrintWriter(System.out);
        Reader scanner = new Reader();
        int n=scanner.nextInt();
        int[] p=new int[n+1];
        for (int i = 1; i <=n ; i++) {
            p[i]=i*i;
        }
        int count=0;
        for (int i = 1; i <=n ; i++) {
            for (int j = 1; j <i ; j++) {
                double t=Math.sqrt(p[i]-p[j]);
                int d=(int)t;
                if (t==d && t<=j)
                    count++;
            }
        }
        System.out.println(count);

        pw.close();

    }

}
/*
class tuple implements Comparable<tuple>{
    int a;
    int b;

    public tuple(int a, int b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public int compareTo(tuple o) {
        return this.a-o.a;
    }
}

 */
class Reader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[64];
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n') break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
        if (neg) return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null) return;
        din.close();
    }
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {
    public void solve() throws Exception {
        int n = nextInt();
        int cnt = 0;
        double EPS = 0.000000001;
        for(int i = 1; i <= n; i++) {
            for(int j = i; j <= n; j++) {
                double r = i*i + j*j;
                r = Math.sqrt(r);
                if(Math.abs(r - Math.floor(r)) < EPS && r <= n)
                    cnt++;
            }
        }
        out.println(cnt);
    }

    public static void main(String[] args) throws Exception {
        A problem = new A();
        problem.solve();
        problem.close();
    }

    BufferedReader in;
    PrintWriter out;
    String curLine;
    StringTokenizer tok;
    final String delimeter = " ";
    final String endOfFile = "";

    public A(BufferedReader in, PrintWriter out) throws Exception {
        this.in = in;
        this.out = out;
        curLine = in.readLine();
        if (curLine == null || curLine == endOfFile) {
            tok = null;
        } else {
            tok = new StringTokenizer(curLine, delimeter);
        }
    }

    public A() throws Exception {
        this(new BufferedReader(new InputStreamReader(System.in)),
                new PrintWriter(System.out));
    }

    public A(String filename) throws Exception {
        this(new BufferedReader(new FileReader(filename + ".in")),
                new PrintWriter(filename + ".out"));
    }

    public boolean hasMore() throws Exception {
        if (tok == null || curLine == null) {
            return false;
        } else {
            while (!tok.hasMoreTokens()) {
                curLine = in.readLine();
                if (curLine == null || curLine.equalsIgnoreCase(endOfFile)) {
                    tok = null;
                    return false;
                } else {
                    tok = new StringTokenizer(curLine);
                }
            }
            return true;
        }
    }

    public String nextWord() throws Exception {
        if (!hasMore()) {
            return null;
        } else {
            return tok.nextToken();
        }
    }

    public int nextInt() throws Exception {
        return Integer.parseInt(nextWord());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextWord());
    }

    public int[] readIntArray(int n) throws Exception {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    public void close() throws Exception {
        in.close();
        out.close();
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Omar-Handouk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Pythagorean_Theorem_II solver = new Pythagorean_Theorem_II();
        solver.solve(1, in, out);
        out.close();
    }

    static class Pythagorean_Theorem_II {
        public void solve(int testNumber, Scanner in, OutputWriter out) {
            int n = in.nextInt();
            //Check for Non-Degenerate Triangle

            int ans = 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)
                        ++ans;
                }
            }

            out.println(ans);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }

    static class Scanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public Scanner(InputStream stream) {
            bufferedReader = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException Error) {
                    Error.printStackTrace();
                    ;
                }
            }

            return stringTokenizer.nextToken();
        }

        public int nextInt() {
            int number = Integer.parseInt(this.next());

            return number;
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task10 solver = new Task10();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task10 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int cnt = 0;

            for (int i = 1; i <= n; i++) {
                for (int j = i; j <= n; j++) {
                    long x = (i * i + j * j);
                    if (Math.sqrt(x) <= n) {
                        if (isPerfectSquare(x)) {
                            cnt++;
                        }
                    }
                }
            }
            out.println(cnt);
        }

        static boolean isPerfectSquare(double x) {

            // Find floating point value of
            // square root of x.
            double sr = Math.sqrt(x);

            // If square root is an integer
            return ((sr - Math.floor(sr)) == 0);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.*;
public class Main{
	public static void main(String [] args){
		Scanner fin = new Scanner(System.in);
		int n = fin.nextInt();
		int res=0;
		for(int a=1;a<=n;a++)
			for(int b=a;b<=n;b++)
			{
				int d = (int)Math.sqrt(a*a+b*b);
				if(d<=n&&d*d==a*a+b*b) res++;

			}
			System.out.println(res);
	}
}

import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

import static java.lang.Math.*;

public class CodeforcesA implements Runnable {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    public static void main(String[] args) {
        new Thread(null, new CodeforcesA(), "", 128 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    void debug(Object... objects) {
        if (DEBUG) {
            for (Object o : objects) {
                System.err.println(o.toString());
            }
        }
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException {

        int n = readInt();
        int ans = 0;

        for (int a = 1; a<=n; a++)
            for (int b = a; b<=n; b++) {
                int c = (int) Math.ceil(Math.sqrt(a*a + b*b));
                if (c>n) break;
                if (c<=n && c*c == a*a + b*b) ans++;
            }

        out.println(ans);

    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class A_183 {
	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;

	static class sort implements Comparable<sort> {
		int x, y;

		public sort(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(sort arg0) {
			if (this.x > arg0.x)
				return 1;
			if (this.x < arg0.x)
				return -1;
			if (this.y > arg0.y)
				return 1;
			if (this.y < arg0.y)
				return -1;
			return 0;
		}
	}

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				System.out)));
		int n = nextInt();
		int[] a = new int[n + 1];
		int ans = 0;
		for (int i = 3; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				double s = Math.sqrt(i * i + j * j);
				if (s == (int) s && s <= n) {
					ans++;
	//				System.out.println(i + " " + j + " " + s);
				}
			}
		}
		System.out.println(ans);
		pw.close();
	}

	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	private static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.text.*;

public class cf304a {

    static BufferedReader br;
    static Scanner sc;
    static PrintWriter out;

    public static void initA() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(System.in);
            //out = new PrintWriter("output.txt");
            out = new PrintWriter(System.out);
        } catch (Exception e) {
        }
    }

    static boolean next_permutation(Integer[] p) {
        for (int a = p.length - 2; a >= 0; --a) {
            if (p[a] < p[a + 1]) {
                for (int b = p.length - 1;; --b) {
                    if (p[b] > p[a]) {
                        int t = p[a];
                        p[a] = p[b];
                        p[b] = t;
                        for (++a, b = p.length - 1; a < b; ++a, --b) {
                            t = p[a];
                            p[a] = p[b];
                            p[b] = t;
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static void initB() {
        try {

            br = new BufferedReader(new FileReader("input.txt"));
            sc = new Scanner(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");

        } catch (Exception e) {
        }
    }

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static Long[] getLongArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Long temp2[] = new Long[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Long.parseLong(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static String[] getStringArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            String temp2[] = new String[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = (temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static void print(String s, Object... a) {
        out.printf(s, a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static void main(String[] ar) {
        initA();
        solve();
        out.flush();
    }

    public static void solve() {
        int n = getInt();

        int o = 0;
        for (int i = 1; i < n; i++) {
            int x;
            for (int j = i; j < n && (x=i * i + j * j) <= n * n; j++) {
                int temp = (int) Math.sqrt(x);
                if (temp*temp == x) {
                    o++;
                    //print(i+" "+j + " "+Math.sqrt(i*i+j*j));
                }
            }
        }
        print(o);

    }
}

import java.util.*;
public class Main {
    public static boolean issquare(int side){
        int third = (int)Math.sqrt(side);
        if((third*third) == side){
            return true;
        }
        else return false;
    }
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int g = sc.nextInt();
    int counter = 0;
    int side =0;
    for(int i=3; i<g-1; i++){
        for(int j=i+1; j<g; j++){
            side = (int)(i*i + j*j);
            if (issquare(side)){
                if(Math.sqrt(side) <=g){
                    //System.out.println(i);
                    counter ++;
                }
                else break;
            }
        }
        if(i> 7022)
            break;
    }

    System.out.println(counter);

}
}

import java.util.Scanner;

/**
 *
 * @author Dell
 */
public class NewMain4 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();

        int count = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = i + 1; j <= x; j++) {
                int z = (i * i) + (j * j);
                if (isPerfectSquare(z) && Math.sqrt(z) <= x) {
                   // System.out.println((i) + " " + (j) + " " + ((i + j)));
                 //   System.out.println((i * i) + " " + (j * j) + " " + ((i + j) * (i + j)));
                    count++;
                }
            }
        }
        System.out.println(count);
    }

    static boolean isPerfectSquare(double x) {

        // Find floating point value of
        // square root of x.
        double sr = Math.sqrt(x);

        // If square root is an integer
        return ((sr - Math.floor(sr)) == 0);
    }
}

import java.io.PrintWriter;
import java.util.*;

public class Program {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        new Program().solve(in, out);

        out.flush();
    }

    boolean find(int[] array, int x, int start) {
        int lo = start;
        int hi = array.length - 1;

        while (lo < hi) {
            int mid = lo + (hi - lo) / 2;
            if (array[mid] == x) {
                return true;
            } else if (x < array[mid]) {
                hi = mid - 1;
            } else {
                lo = mid + 1;
            }
        }

        return array[lo] == x;
    }
    void solve(Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] squares = new int[n + 1];

        for (int i = 1; i <= n; i++) {
            squares[i] = i * i;
        }

        int count = 0;
        for (int a = 1; a <= n; a++) {
            for (int b = a + 1; b <= n; b++) {
                int c = squares[a] + squares[b];
                if (c > squares[squares.length - 1]) {
                    break;
                }

                int c2 = (int) Math.sqrt(c);
                if (c2 * c2 == c) {
                    count++;
                }
            }
        }

        out.println(count);
    }
}

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;

public class Solution {
    //--------------SOLUTION--------------//
    public static void main(String[] args) {
        Reader in = new Reader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        out.println(solve(in.nextInt()));
        out.close();
    }

    private static long solve(int n) {
        int res = 0;

        double c , cFloor;
        int maxA = (int) (n / Math.sqrt(2));
        for(int a = 3;a <= maxA;a++) {
            for(int b = a + 1;b < n;b++) {
                c = Math.sqrt(a * a + b * b);
                cFloor = (long) c;

                if(cFloor <= n && c - cFloor == 0.0) { res++; }
            }
        }

        return res;
    }
    //--------------SOLUTION--------------//

// EeeeEeEyyYYy bOss cAn i haBE anY pUuSSyYy plssSSsSss //

    //--------------FAST READER--------------//
    private static class Reader {
        private int pos;
        private String[] tokens;
        private BufferedReader reader;

        private Reader(InputStream in) {
            pos = 0;
            tokens = null;
            reader = new BufferedReader(new InputStreamReader(in));
        }

         public String next() {
            while(tokens == null || pos == tokens.length) {
                try {
                    String line = reader.readLine();
                    tokens = line != null ? line.split("\\s") : null;
                    pos = 0;
                } catch(IOException e) {
                    e.printStackTrace();
                }
            }

            return tokens[pos++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];

            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }

            return a;
        }
    }
    //--------------FAST READER--------------//
}

import java.util.*;
public class PythagoreanTheoremII{
   public static void main(String[] Args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long ans =0;
      for(int k =1;k<=n;k++){
         for(int j =1;j * j * 2 < k * k;j++){
            int bb = k*k-j*j;
            int b = (int)Math.sqrt(.5 + bb);
            if(b*b+j*j==k*k)
               ans++;
         }
      }
      System.out.println(ans);
   }
}

import java.util.*;
public class Pythagoras {
public static void main(String [] args){
Scanner in =new Scanner(System.in);
int n=in.nextInt();
int cnt=0;
for(int i=5;i<=n;i++){
for(int j=i-1;j>=i/Math.sqrt(2);j--){
if(Math.sqrt(i*i-j*j)==(int)Math.sqrt(i*i-j*j)){
cnt++;
//System.out.println(i+" "+j);
}
}
}
System.out.print(cnt);
}
}

import java.io.*;
import java.util.Scanner;
import java.util.Arrays;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) throws IOException {

        Scanner scanner = new Scanner(System.in);

        int n;
        long count = 0;

        n = scanner.nextInt();

        for (int i = 1; i < 100; i++) {

            for (int j = i + 1; j < 100; j++) {

                if (gcd(j , i) == 1 && (i % 2 == 0 || j % 2 == 0) && (i * i) + (j * j) <= n) {
                    count += (n / ((i * i) + (j * j)));
                }
            }
        }

        System.out.println(count);
    }

     public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;

        return gcd(b%a, a);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_304_A_PYTHAGOREAN_THEOREM_II {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int count = 0;
		for(long a=1 ; a<=n ; a++)
			for(long b = a ;b<=n ;b++)
			{
				long f1 = a*a;
				long f2 = b*b;

				long res = (long)Math.sqrt(f1+f2);

				if(res*res == f1+f2 && res>=b&& res<=n)
					count++;

			}

		System.out.println(count);

	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}

import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;

public class Main {
	public Main() throws IOException {
		String input;

		input = br.readLine();
		work(input);

		System.out.print(sb);
	}

	private int getGCF(int x , int y) {
		int a = 0 , b = 0 , c = 0 ;

		if ( x > y ) {
			a = x ;
			b = y;
		} else {
			a = y ;
			b = x;
		}

		do {
			c = a % b;

			if (c!=0) {
				a = b ;
				b = c ;
			}
		} while (c != 0);

		return b;
	}

	private void work(String input) throws IOException {
		//debug(t, input);
		int ret = 0;
		String[] inputArray = input.split(" ");
		int n = Integer.valueOf(inputArray[0]);

		for (int i = 2; i < Math.sqrt(n) + 1; i++) {
			for (int j = 1; j < i; j++) {
				if ((getGCF(i, j) != 1) || ((i + j) % 2 == 0))
					continue;

				int a = i * i - j * j;
				int b = a * i * j;
				int c = i * i + j * j;

				ret += n / c;
			}
		}

		sb.append(ret);
	}

	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(
		new InputStreamReader(System.in));

	public static void main(String[] args) throws IOException {
			new Main();
	}

	public static void debug(Object... arr) {
		System.err.println(Arrays.deepToString(arr));
	}
}

import java.util.Scanner;
public class Main {
    public static void main (String args[]){
        Scanner scan = new Scanner (System.in);
        while (scan.hasNextInt()){
            int n = scan.nextInt();
            int counter = 0;
            for (int i = 1; i < n; i ++){
                for (int j = i; j < n; j ++){
                    int c = i*i + j*j;
                    double d = Math.sqrt(c);
                    if (d <= n && d%1 == 0) {
                        counter ++;
                    }
                }
            }
        System.out.println(counter);

        }
        scan.close();
    }

}

import java.io.File;
import java.io.FileNotFoundException;
    import java.util.*;
import javafx.util.Pair;

    public class Main {

        public static void main(String[] args) throws FileNotFoundException {

            Scanner input = new Scanner(System.in);

           int n = input.nextInt();

            int count=0;
            for (int i = 1; i <=n;i++) {
                for (int j =i; j <=n; j++) {
                    int k = (int) Math.sqrt(i*i+j*j);
                    if(k*k==i*i+j*j&&k<=n)
                    {

                        count++;
                    }

                }
            }
            System.out.println(count);

        }

    }

import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.awt.Point;
import java.math.BigInteger;

import static java.lang.Math.*;

public class CodeforcesA implements Runnable {

    final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    public static void main(String[] args) {
        new Thread(null, new CodeforcesA(), "", 128 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    void debug(Object... objects) {
        if (DEBUG) {
            for (Object o : objects) {
                System.err.println(o.toString());
            }
        }
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            time();
            memory();
        } catch (Exception e) {
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    boolean DEBUG = false;

    void solve() throws IOException {

        int n = readInt();
        int ans = 0;

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

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

        out.println(ans);

    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF_183_A {

    double eps = 10e-8;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();

        int count = 0;

        for(int i = 1; i<n; i++){
            for(int j = 1; j<=i; j++){
                int c2 = i*i + j*j;
                double c = Math.sqrt(c2);
                if(c2<= n*n && c2 > j*j && c2>i*i && c==Math.round(c)) {
                    //System.out.println(j+" "+i+ " "+c);
                    count++;
                }
            }
        }

        System.out.println(count);

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble(){
            return Double.parseDouble(next());
        }
    }

}

import java.util.Scanner;

public class Triangle {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();

		int count = 0;

		for (int c1=2; c1<n; c1++) {
			for(int c2=2; c2<=c1; c2++) {
				double sqrt = Math.sqrt((c1*c1)+(c2*c2));
				if(sqrt == Math.floor(sqrt)) {
					if ((int)sqrt <= n) {
						count++;
					}
				}
			}
		}

		System.out.println(count);
		s.close();
	}
}

import static java.lang.Math.sqrt;
import java.util.Scanner;

public class P6 {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int count = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                if ((i * i + j * j <= n * n) && (i * i + j * j >= 1) &&(sqrt(i*i+j*j)==(int)sqrt(i*i+j*j)) ){
                    count++;
                }
            }
        }
        System.out.println(count);

    }

}

import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter/*(new File("Omar.txt"));*/(System.out);

int n=Integer.parseInt(br.readLine());

        int counter;

            counter=0; int c;
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++) {
                c = i * i + j * j;
                c = (int) Math.sqrt(c);

                if (i * i + j * j == c*c &&c<=n) {
                    counter++;

                }
            }
            }

 pw.print(counter);
pw.print('\n');
       // System.out.println(Arrays.toString(a));
//        counter+=Math.min(less,greater);

        br.close();
        pw.close();
    }
}

// CodeForces Round #332 B Done

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Pifagor {

	int n;
	long nt;

	private void readData(BufferedReader bin) throws IOException {
		String s = bin.readLine();
		String []ss = s.split(" ");
		n = Integer.parseInt(ss[0]);
	}

	void printRes() {
		System.out.println(nt);
	}

	private void calculate() {
		int a,b,c;
		nt = 0;
		for (a=1; a<n; a++) {
			for (b=a; b<n; b++) {
				double fc = Math.sqrt(a*a + b*b);
				c = (int)fc;
				if (c*c == (a*a + b*b) && c<=n) {
					nt++;
				}
			}
		}
	}

	public static void main(String[] args) throws IOException {
		// BufferedReader bin = new BufferedReader(new FileReader("cactus.in"));
		BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
		Pifagor l = new Pifagor();
		l.readData(bin);
		l.calculate();
		l.printRes();
	}
}

import java.util.*;
import java.io.*;

public class pytha
{

   public static void main (String[] args) throws Exception{
    Scanner sc=new Scanner(System.in);
    long n=sc.nextLong();
    int cnt=0;
    for(int a=1;a<=n;a++){
      for(int b=a+1;b<=n;b++){
             int cc=a*a+b*b;
             int c=(int)Math.sqrt(cc);
             if(c*c==cc && c<=n){
              cnt++;
             }
            // System.out.println(c);

      }
    }
    System.out.println(cnt);

}

    }

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class A {

  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int N = Integer.parseInt(br.readLine().trim());

    long ans = 0;
    for (int a = 1; a <= N; a++) {
      for (int b = a; b <= N; b++) {
        long c2 = a * a + b * b;
        int c = (int) Math.sqrt(c2);
        if (c * c == c2 && c <= N)
          ans++;
      }
    }
    out.println(ans);

    br.close();
    out.close();
  }
}

import java.util.Scanner;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int a = 0;
        int b = 0;
        for (int i = 1; i <= n; ++i){
            for (int j = i + 1; j <= n; ++j){
                double pyth = i*i + j*j;
                pyth = Math.sqrt(pyth);
                double diff = pyth - (long)pyth;
                if (diff == 0.0 && (long)pyth <= n)a++;

            }
        }
        out.print(a);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
    public static int findPythagorean(int L){
        int  count = 0;
        for(int b=1; b<L; b++){
            for(int a=1; a<=b && (a*a) + (b*b)<=(L*L); a++){

                double cSquare = a*a + b*b;
                double c = Math.sqrt(cSquare);
                if(a+b<=c){
                    break;
                }
                if(c==Math.round(c) && c<=L){
                    count++;
                }
            }
        }
        System.out.printf("%d\n", count);
        return count;
    }

    public static void main(String args[]){
        Scanner keyboard = new Scanner(System.in);
        int L = keyboard.nextInt();
        findPythagorean(L);
    }
}

import java.util.Scanner;

public class A304 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int answer = 0;
        for (int a=1; a<=N; a++) {
            int aa = a*a;
            for (int b=a; b<=N; b++) {
                int bb = b*b;
                double c = Math.sqrt(bb+aa);
                if (c == (int) c && c <= N) {
                    answer++;
                }
            }
        }
        System.out.println(answer);
    }

}

public class Main {
    public static void main(String[] args) {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int n = sc.nextInt();
        int c = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                double x = Math.pow(i, 2) + Math.pow(j, 2);
                if(Math.sqrt(x) == (int)Math.sqrt(x) && Math.pow(i, 2) + Math.pow(j, 2) <= Math.pow(n, 2))
                    c++;
            }
        }
        System.out.println(c);
    }
}

import java.util.*;

public class PythagTheorem304A
{
    public static void main(String[] args)
    {
        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter n");
        int n = sc.nextInt();

        int answer = 0;
        for (int a=3; a<=n; a++)
        {
            for (int b=a+1; b<=n; b++)
            {
                double testc = Math.sqrt(a*a + b*b);
                if (testc > n)
                {
                    break;
                }
                else
                {
                    double trunc = (int)(testc) * 1.0;
                    if (Math.abs(testc - trunc) < 0.000001)
                    {
                        answer++;
                    }
                }
            }
        }
        System.out.println(answer);
    }
}

import java.io.PrintWriter;
import java.util.Scanner;

public class C183D2A {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();

        int res = 0;
        for (int a = 1; a < n; a++) {
            for (int b = a; b < n; b++) {
                int k = a*a + b*b;
                int d = (int) Math.sqrt(k);
                if (k > n*n) break;
                if (k == d*d) {
                    res++;
                }
            }
        }

        out.println(res);
        out.flush();
    }
}

import java.util.Scanner ;
public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner ( System.in ) ;
		int n = in.nextInt() ;

		if ( n < 1 || n > 10000 )
			return ;

		int counter = 0 ;

		for ( int a = 1 ; a <= n ; a ++ )
		{
			int B = (int) Math.sqrt ( n*n - a * a ) + 1 ;

			for ( int b = a ; b < B ; b ++ )
			{
				int C = a*a + b*b ;
				int c = (int) Math.sqrt( C ) ;
				if ( c <= n && c * c == C )
					counter ++ ;
			}
		}
		System.out.println(counter) ;
	}

}

//package geometry;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;
/**
 *
 * @author prabhat // use stringbuilder,TreeSet, priorityQueue
 */
   public class  point4{
   public  static long[] BIT;
   public  static int[] tree,lazy;
   public  static long[] sum;
   public  static int mod=1000000007;
   public  static int[][] dp;
   public  static boolean[][] isPalin;
   public  static int max1=100005;
   public  static int[][] g;
   public  static LinkedList<Pair> l[],pp;
   public static Query[] query;
   public  static int n,m,q,k,t,x,y,a[],b[],arr[],chosen[],pos[],val[],blocksize,count=0,size[],tin[],len,
                                                          tout[],discover[],cnt[],pre[],cnty[],cntZ[];
   public  static long V[],low,high,min=Long.MAX_VALUE,cap[],has[],max,ans;
   public  static ArrayList<Integer> adj[],al[];
   public  static TreeSet<Integer> ts;
   public  static char s[][];
   public  static int depth[],mini,maxi;
   public  static boolean visit[][],isPrime[],used[][];
   public  static int[][] dist;
   public  static ArrayList<Integer>prime;
   public  static int[] x1={0,0,-1,1};
   public  static int[] y1={-1,1,0,0};
   public  static ArrayList<Integer> divisor[]=new ArrayList[1000005];
   public  static  int[][] subtree,parent,mat;
   public  static  TreeMap<Integer,Integer> tm;
   public  static LongPoint[] p;
   public  static int[][] grid,memo;
   public  static ArrayList<Pair> list[];
   public  static TrieNode root,node[];
   public  static  LinkedHashMap<String,Integer> map;
   public  static ArrayList<String> al1;
   public static int upper=(int)(1e7);
   public  static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   public  static void main(String[] args) throws Exception
   {
   	   InputReader in = new InputReader(System.in);
	   PrintWriter pw=new PrintWriter(System.out);
	   n=in.ii();
	   int ans=0;
	   for(int a=1;a<=n;a++)
	   {
		   for(int b=a;b<=n;b++)
		   {
			   int c=a*a+b*b;
			   int d=c;
			   c=(int)Math.sqrt(c);
             if(c*c==d&&c<=n)ans++;
		   }
	   }
	   pw.println(ans);
	   pw.close();
}
static int canwin(int u,int v,int k,int[][][]memo)
{
 if(memo[u][v][k]!=-1)return memo[u][v][k];
  else{
	  if(k==0||s[u][v]=='E')return 0;
	  else{
		  int res=0;
		  for(int i=0;i<4;i++)
		  {
			  int nx=u+x1[i];
			  int ny=v+y1[i];
			  if(valid(nx, ny)&&s[nx][ny]!='#')
			   {
				   if(canwin(nx,ny,k-1,memo)==0)
				    res=1;
			   }
		  }
		  memo[u][v][k]=res;
	  }
      return memo[u][v][k];
  }

}

static void rotate(int[] x,int[] y)
{
	for(int i=0;i<x.length;i++)
	{
		int xx=x[i];
		x[i]=y[i];
		y[i]=n-xx+1;
	}
	int t=n;
	n=m;
	m=t;
}
static void hori(int[] y)
{
	for(int i=0;i<y.length;i++)
	{
       y[i]=m-y[i]+1;
	}
}
static int lcs(String s1,String s2)
{
	int n=s1.length();
	int m=s2.length();
	int[][] temp=new int[n+1][m+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0||j==0)temp[i][j]=0;
			else if(s1.charAt(i-1)==s2.charAt(j-1))temp[i][j]=temp[i-1][j-1]+1;
			else temp[i][j]=Math.max(temp[i-1][j],temp[i][j-1]);
		}
	}
	return temp[n][m];
}
static void mergeSort(int[] a, int p, int r)
{
	if( p < r )
	{
		int q = (p + r) / 2;
		mergeSort(a, p, q);
		mergeSort(a, q + 1, r);
		merge(a, p, q, r);
	}
}

static void merge(int[] a, int p, int q, int r)
{
   int n1 = q - p + 1;
   int n2 = r - q;
   int[] L = new int[n1+1], R = new int[n2+1];

   for(int i = 0; i < n1; i++)  L[i] = a[p + i];
   for(int i = 0; i < n2; i++)  R[i] = a[q + 1 + i];
   L[n1] = R[n2] = Integer.MAX_VALUE;

   for(int k = p, i = 0, j = 0; k <= r; k++)
	   if(L[i] <= R[j])
		   a[k] = L[i++];
	   else
		   a[k] = R[j++];
}
static int determineUsage(int[] distance, int[] height)
{
   int maxX=0;
   int maxY=0;
   int n=height.length;
   int[] preX=new int[n+1];
   preX[0]=0;
   for(int i:height)maxY=Math.max(maxY,i);
   for(int i=0;i<distance.length;i++){
	   preX[i+1]=preX[i]+distance[i];
   }
   int ans=Integer.MAX_VALUE;
   for(int i=0;i<n;i++)
   {
	   outer:
	   for(int j=i+1;j<n;j++)
	   {
			int cnt=0;
			for(int k=0;k<n;k++)
			{
				if(k!=i){
					 if((-height[i])*(preX[j]-preX[i])-(height[j]-height[i])*(preX[k]-preX[i])>0)continue outer;
					 int d=(height[k]-height[i])*(preX[j]-preX[i])-(height[j]-height[i])*(preX[k]-preX[i]);
					 if(d>0)cnt++;
					 if(d<0)continue outer;
				}
			}
			ans=Math.min(cnt,ans);
	   }
   }
   return ans==Integer.MAX_VALUE?n-1:ans;
}
static int ori(int x1,int y1,int x2,int y2,int x3,int y3)
{
	int X1=x3-x1;
	int Y1=y3-y1;
	int X2=x2-x1;
	int Y2=y2-y1;
  return (X1*Y2-X2*Y1);
}

static class Node{
	int gcd,cnt;
	public Node(int gcd,int cnt)
	{
		this.gcd=gcd;
		this.cnt=cnt;
	}
}

		static  void build(int node,int start,int end){
			if(start > end)return;
			if(start == end){
				tree[node] = arr[start];
				return;
			}
			build(2*node,start,(start + end)/2);
			build(2*node + 1,(start + end)/2 + 1,end);
			tree[node] = Math.min(tree[2*node],tree[2*node + 1]);
		}
		static  void update(int node,int start,int end,int i,int j,int val){
			if(lazy[node] != 0){
				tree[node] += lazy[node];
				if(start != end){
					lazy[2*node] += lazy[node];
					lazy[2*node + 1] += lazy[node];
				}
				lazy[node] = 0;
			}
			if(start > end || start > j || end < i)return;
			if(start >= i && end <= j){
				tree[node] += val;
				if(start != end){
				  lazy[2*node] += val;
				  lazy[2*node + 1] += val;
				}
				return;
			}
			update(2*node,start,(start + end)/2,i,j,val);
			update(2*node + 1,(start + end)/2 + 1,end,i,j,val);
			tree[node] = Math.min(tree[2*node],tree[2*node + 1]);
		}
		static int query(int node,int start,int end,int i,int j){
			if(start > end || start > j || end < i)return Integer.MAX_VALUE;
			if(lazy[node] != 0){
				tree[node] += lazy[node];
				if(start != end){
					lazy[2*node] += lazy[node];
					lazy[2*node + 1] += lazy[node];
				}
				lazy[node] = 0;
			}
			if(start >= i && end <= j)return tree[node];
			int q1 = query(2*node,start,(start + end)/2,i,j);
			int q2 = query(2*node + 1,(start + end)/2 + 1,end,i,j);
			return Math.min(q1,q2);
		}

static int get(int u, int d){

	for(int i = len - 1; i >= 0; i--){

		if(d >= 1 << i){
			d -= 1 << i;
			u = parent[i][u];
		}

	}

	return u;
}
 static void dfs(int u, int p) {
	tin[u] = count++;
	parent[0][u] = p;
	size[u]++;
	for (int i = 1; i < len; i++)
		parent[i][u] = parent[i - 1][parent[i - 1][u]];
	for (int v :adj[u])
		if (v != p)
		{
			depth[v] = depth[u] + 1;
			dfs( v, u);
			size[u] += size[v];
		}

	tout[u] = count++;
}

static boolean isParent(int parent, int child) {
	return tin[parent] <= tin[child] && tout[child] <= tout[parent];
}

static int lca(int a, int b) {
	if (isParent(a, b))
		return a;
	if (isParent(b, a))
		return b;
	for (int i = len - 1; i >= 0; i--)
		if (!isParent(parent[i][a], b))
			a = parent[i][a];
	return parent[0][a];
}

static class TrieNode
{
	int value;  // Only used in leaf nodes
	int freq;
	TrieNode[] arr =  new TrieNode[2];
	public TrieNode() {
		value = Integer.MAX_VALUE;
		freq=0;
		arr[0] = null;
		arr[1] = null;
	}
}
static void insert(int n,int num)
{
	TrieNode temp = node[n];
	temp.value=Math.min(temp.value,num);
	// Start from the msb, insert all bits of
	// pre_xor into Trie
	for (int i=19; i>=0; i--)
	{
		// Find current bit in given prefix
		int val = (num & (1<<i)) >=1 ? 1 : 0;

		// Create a new node if needed
		if (temp.arr[val] == null)
			temp.arr[val] = new TrieNode();

		temp = temp.arr[val];

		temp.value=Math.min(temp.value,num);
	}
//  System.out.println(temp.value);
	// Store value at leaf node
	//temp.value = pre_xor;
}

static long query(int x,int k,int s)
{
	TrieNode temp = node[k];
	long ans=0;
	if(x%k!=0||temp.value+x>s)return -1;

	for (int i=19; i>=0; i--)
	{
		// Find current bit in given prefix
		int val = (x & (1<<i)) >= 1 ? 1 : 0;

		if(temp.arr[1^val]!=null&&temp.arr[1^val].value+x<=s)
		{
			ans+=(1^val)<<i;
			temp=temp.arr[1^val];
		}
        else if(temp.arr[val]!=null){
			ans+=val<<i;
			temp=temp.arr[val];
			if(temp==null||temp.value+x>s)
			{
				return -1;
			}
		}
	}
	return ans;
}

static void update(int indx,long val)
   {
	   while(indx<max1)
	   {
		   BIT[indx]=Math.max(BIT[indx],val);
		   indx+=(indx&(-indx));
	   }

   }
static long query1(int indx)
   {
	   long sum=0;
	   while(indx>=1)
	   {
		  sum=Math.max(BIT[indx],sum);
		   indx-=(indx&(-indx));
	   }
	   return sum;
	}

static void Seive()
{
	isPrime=new boolean[max1];
	Arrays.fill(isPrime,true);
	for(int i=1;i<max1;i++)divisor[i]=new ArrayList<Integer>();
    isPrime[0]=isPrime[1]=false;
	for(int i=1;i<(max1);i++)
	{
        //  if(isPrime[i])
			for(int j=i;j<max1;j+=i)
			{
				//isPrime[j]=false;
				divisor[j].add(i);
			}
	//	divisor[i].add(i);
	}
}
static int orient(Point a,Point b,Point c)
{
	//return (int)(c.x-a.x)*(int)(b.y-a.y)-(int)(c.y-a.y)*(int)(b.x-a.x);
	Point p1=c.minus(a);
	Point p2=b.minus(a);
	return (int)(p1.cross(p2));
}
public static class Polygon {

	static final double EPS = 1e-15;
	public int n;
	public Point p[];

	Polygon(int n, Point x[]) {
		this.n = n;
		p = Arrays.copyOf(x, n);
	}

	long area(){ //returns 2 * area
		long ans = 0;
		for(int i = 1; i + 1 < n; i++)
			ans += p[i].minus(p[0]).cross(p[i + 1].minus(p[0]));
		return ans;
	}

	boolean PointInPolygon(Point q) {
		boolean c = false;
		for (int i = 0; i < n; i++){
			int j = (i+1)%n;
			if ((p[i].y <= q.y && q.y < p[j].y ||
					p[j].y <= q.y && q.y < p[i].y) &&
					q.x < p[i].x + (p[j].x - p[i].x) * (q.y - p[i].y) / (p[j].y - p[i].y))
			c = !c;
		 }
		return c;
	}

		// determine if point is on the boundary of a polygon
	boolean PointOnPolygon(Point q) {
		 for (int i = 0; i < n; i++)
		 if (ProjectPointSegment(p[i], p[(i+1)%n], q).dist(q) < EPS)
			 return true;
		 return false;
	}

	// project point c onto line segment through a and b
	Point ProjectPointSegment(Point a, Point b, Point c) {
	  double r = b.minus(a).dot(b.minus(a));
	  if (Math.abs(r) < EPS) return a;
	  r = c.minus(a).dot(b.minus(a))/r;
	  if (r < 0) return a;
	  if (r > 1) return b;
	  return a.plus(b.minus(a).mul(r));
	}
}

public static class Point {
	public double x, y;

	public Point(double x, double y) {
		this.x = x;
		this.y = y;
	}

	public Point minus(Point b) {
		return new Point(x - b.x, y - b.y);
	}

	public Point plus(Point a){
		return new Point(x + a.x, y + a.y);
	}

	public double cross(Point b) {
		return (double)x * b.y - (double)y * b.x;
	}

	public double dot(Point b) {
		return (double)x * b.x + (double)y * b.y;
	}

	public Point mul(double r){
		return new Point(x * r, y * r);
	}

	public double dist(Point p){
		return Math.sqrt(fastHypt( x - p.x , y - p.y));
	}

	public double fastHypt(double x, double y){
		return x * x + y * y;
	}
}
static class Query implements Comparable<Query>{
	int index,k;
	int L;
	int R;
	public Query(){}
	public Query(int a,int b,int index)
	{
	  this.L=a;
	  this.R=b;
	  this.index=index;
	}
   public int compareTo(Query o)
   {
	  if(L/blocksize!=o.L/blocksize)return L/blocksize-o.L/blocksize;
	  else return R-o.R;
   }

 }

static double dist(Point p1,Point p2)
{
	return Math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}

static class coder {
	int indx;
	String name;
	coder(int indx,String name)
	{
		this.indx=indx;
		this.name=name;
	}
}

static int gcd(int a, int b)
{
	int res=0;
	while(a!=0)
	{
		res=a;
		a=b%a;
		b=res;
	}
	return b;
}
static slope getSlope(Point p, Point q)
	{
		int dx = (int)(q.x - p.x), dy = (int)(q.y - p.y);
		int g = gcd(dx, dy);
		return new slope(dy / g, dx / g);
	}

static class slope implements Comparable<slope>
{
	int x,y;
	public slope(int y,int x)
	{
		this.x=x;
		this.y=y;
	}
	public int compareTo(slope s)
	{
		if(s.y!=y)return y-s.y;
	return x-s.x;
	}
}

static class Ball implements Comparable
	{
		int r;
		int occ;
		public Ball(int r,int occ)
		{
			this.r = r;
			this.occ = occ;
		}
		@Override
		public int compareTo(Object o) {
			Ball b = (Ball) o;
			return b.occ-this.occ;
		}
	}

static class E implements Comparable<E>{
	int x,y;
	char c;
	E(int  x,int y,char c)
	{
		this.x=x;
		this.y=y;
		this.c=c;
	}
	public int compareTo(E o)
	{
		if(x!=o.x)return o.x-x;
		else return y-o.y;

	}
}

   public static ListNode removeNthFromEnd(ListNode a, int b) {

    int cnt=0;
	ListNode ra1=a;
	ListNode ra2=a;
	while(ra1!=null){ra1=ra1.next; cnt++;}

	if(b>cnt)return a.next;
	else if(b==1&&cnt==1)return null;
	else{
		int y=cnt-b+1;
		int u=0;
		ListNode prev=null;
		while(a!=null)
		{
			u++;
		   if(u==y)
		   {
			   if(a.next==null)prev.next=null;
			   else
			   {
				   if(prev==null)return ra2.next;
				   prev.next=a.next;
				   a.next=null;
			   }
			   break;
		   }
		   prev=a;
		   a=a.next;
		}
	}
	return ra2;
}
   static ListNode rev(ListNode a)
   {
       ListNode prev=null;
       ListNode cur=a;
       ListNode next=null;
       while(cur!=null)
       {
           next=cur.next;
           cur.next=prev;
           prev=cur;
           cur=next;
       }
       return prev;
   }

  static class ListNode {
	     public int val;
	     public ListNode next;
	     ListNode(int x) { val = x; next = null; }
	 }

   public static String add(String s1,String s2)
   {
	   int n=s1.length()-1;
	   int m=s2.length()-1;
	   int rem=0;
	   int carry=0;
	   int i=n;
	   int j=m;
	   String ans="";
	   while(i>=0&&j>=0)
	   {
		 int c1=(int)(s1.charAt(i)-'0');
		 int c2=(int)(s2.charAt(j)-'0');
		 int sum=c1+c2;
		 sum+=carry;
		 rem=sum%10;
		 carry=sum/10;
         ans=rem+ans;
		  i--; j--;

	   }
	   while(i>=0)
	   {
		int c1=(int)(s1.charAt(i)-'0');

		int sum=c1;
		sum+=carry;
		rem=sum%10;
		carry=sum/10;
		ans=rem+ans;
		i--;
	   }
	   while(j>=0)
	   {

		int c2=(int)(s2.charAt(j)-'0');
		int sum=c2;
		sum+=carry;
		rem=sum%10;
		carry=sum/10;
		ans=rem+ans;
		j--;
	   }

	   if(carry>0)ans=carry+ans;
	   return ans;
   }
   public static String[] multiply(String A, String B) {
	int lb=B.length();
	char[] a=A.toCharArray();
	char[] b=B.toCharArray();
	String[] s=new String[lb];
	int cnt=0;
	int y=0;
	String s1="";
q=0;
	for(int i=b.length-1;i>=0;i--)
	{
		int rem=0;
		int carry=0;

		for(int j=a.length-1;j>=0;j--)
		{
			int mul=(int)(b[i]-'0')*(int)(a[j]-'0');
			mul+=carry;
			rem=mul%10;
			carry=mul/10;
			s1=rem+s1;
		}
		s1=carry+s1;
		s[y++]=s1;
		q=Math.max(q,s1.length());
		s1="";
		for(int i1=0;i1<y;i1++)s1+='0';

	}
	return s;
}
   public static long nCr(long total, long choose)
   {
	   if(total < choose)
		   return 0;
	   if(choose == 0 || choose == total)
		   return 1;
	   return nCr(total-1,choose-1)+nCr(total-1,choose);
   }

   static int get(long s)
   {
	  int ans=0;
	  for(int i=0;i<n;i++)
	  {
		  if(p[i].x<=s&&s<=p[i].y)ans++;
	  }
	  return ans;
   }
   static class LongPoint {
	public long x;
	public long y;

	public LongPoint(long x, long y) {
		this.x = x;
		this.y = y;
	}

	public LongPoint subtract(LongPoint o) {
		return new LongPoint(x - o.x, y - o.y);
	}

	public long cross(LongPoint o) {
		return x * o.y - y * o.x;
	}

}
    static int CountPs(String s,int n)
       {
    	boolean b=false;
    	     char[] S=s.toCharArray();
	       int[][] dp=new int[n][n];
	       boolean[][] p=new boolean[n][n];
	       for(int i=0;i<n;i++)p[i][i]=true;

	       for(int i=0;i<n-1;i++)
	       {
	    	   if(S[i]==S[i+1])
	    	   {
	    		p[i][i+1]=true;
	    		dp[i][i+1]=0;
	    		b=true;
	    	   }
	       }

	       for(int gap=2;gap<n;gap++)
	       {
	    	   for(int i=0;i<n-gap;i++)
	    	   {
	    		   int j=gap+i;
	    		   if(S[i]==S[j]&&p[i+1][j-1]){p[i][j]=true;}

	    		  if(p[i][j])
	    			   dp[i][j]=dp[i][j-1]+dp[i+1][j]+1-dp[i+1][j-1];

	    		   else if(!p[i][j]) dp[i][j]=dp[i][j-1]+dp[i+1][j]-dp[i+1][j-1];

	    		   //if(dp[i][j]>=1)
                             //  return true;
	    	   }
	       }

	   // return b;
    return dp[0][n-1];

    }

  static long divCeil(long a,long b)
  {
      return (a+b-1)/b;
  }
  static long root(int pow, long x) {
        long candidate = (long)Math.exp(Math.log(x)/pow);
        candidate = Math.max(1, candidate);
        while (pow(candidate, pow) <= x) {
            candidate++;
        }
        return candidate-1;
    }

    static long pow(long x, int pow)
    {
        long result = 1;
        long p = x;
        while (pow > 0) {
            if ((pow&1) == 1) {
                if (result > Long.MAX_VALUE/p) return Long.MAX_VALUE;
                result *= p;
            }
            pow >>>= 1;
            if (pow > 0 && p >= 4294967296L) return Long.MAX_VALUE;
            p *= p;
        }
        return result;
    }

  static boolean valid(int i,int j)
  {
	  if(i>=0&&i<n&&j>=0&&j<m)return true;
	  return false;
  }
  private static class DSU{
		int[] parent;
		int[] rank;
		int cnt;
		public DSU(int n){
			parent=new int[n];
			rank=new int[n];
			for(int i=0;i<n;i++){
				parent[i]=i;
				rank[i]=1;
			}
			cnt=n;
		}
		int find(int i){
	        while(parent[i] !=i){
	        	parent[i]=parent[parent[i]];
	        	i=parent[i];
	        }
	        return i;
	    }
		int Union(int x, int y){
	        int xset = find(x);
	        int yset = find(y);
	        if(xset!=yset)
	        	cnt--;
	        if(rank[xset]<rank[yset]){
	        	parent[xset] = yset;
		        rank[yset]+=rank[xset];
		        rank[xset]=0;
		        return yset;
	        }else{
	        	parent[yset]=xset;
	        	rank[xset]+=rank[yset];
	        	rank[yset]=0;
	        	return xset;
	        }
	    }
	}
  public static int[][] packU(int n, int[] from, int[] to, int max) {

	    int[][] g = new int[n][];
	    int[] p = new int[n];
	    for (int i = 0; i < max; i++) p[from[i]]++;
	    for (int i = 0; i < max; i++) p[to[i]]++;
	    for (int i = 0; i < n; i++) g[i] = new int[p[i]];
	    for (int i = 0; i < max; i++) {
	        g[from[i]][--p[from[i]]] = to[i];
	        g[to[i]][--p[to[i]]] = from[i];
	    }
	    return g;
	}
	public static int[][] parents3(int[][] g, int root) {
	    int n = g.length;
	    int[] par = new int[n];
	    Arrays.fill(par, -1);

	    int[] depth = new int[n];
	    depth[0] = 0;

	    int[] q = new int[n];
	    q[0] = root;
	    for (int p = 0, r = 1; p < r; p++) {
	        int cur = q[p];
	        for (int nex : g[cur]) {
	            if (par[cur] != nex) {
	                q[r++] = nex;
	                par[nex] = cur;
	                depth[nex] = depth[cur] + 1;
	            }
	        }
	    }
	    return new int[][]{par, q, depth};
	}
	public static int lower_bound(int[] nums, int target) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + (high - low) / 2;
            if (nums[mid] < target)
                low = mid + 1;
            else
                high = mid;
        }
        return nums[low] == target ? low : -1;
    }

    public static int upper_bound(int[] nums, int target) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + (high + 1 - low) / 2;
            if (nums[mid] > target)
                high = mid - 1;
            else
                low = mid;
        }
        return nums[low] == target ? low : -1;
    }
  public static boolean palin(String s)
	{
	   int i=0;
	   int j=s.length()-1;
	   while(i<j)
	   {
		   if(s.charAt(i)==s.charAt(j))
		   {
			   i++;
			   j--;
		   }
		   else return false;
	   }
	   return true;
	}

static int lcm(int a,int b)
{
	return (a*b)/(gcd(a,b));
}

public static long pow(long n,long p,long m)
{
	 long  result = 1;
	  if(p==0)
	    return 1;

	while(p!=0)
	{
	    if(p%2==1)
	        result *= n;
	    if(result>=m)
	    result%=m;
	    p >>=1;
	    n*=n;
	    if(n>=m)
	    n%=m;
	}
	return result;
}

    /**
     *
     * @param n
     * @param p
     * @return
     */
    public static long pow(long n,long p)
     {
	long  result = 1;
	  if(p==0)
	    return 1;
	if (p==1)
	    return n;
	while(p!=0)
	{
	    if(p%2==1)
	        result *= n;
	    p >>=1;
	    n*=n;
	}
	return result;

     }

static class Edge implements Comparator<Edge> {
	private int u;
	private int v;
	private long w;
	public Edge() {
	}
	public Edge(int u, int v, long w) {
		this.u=u;
		this.v=v;
		this.w=w;
	}
	public int getU() {
		return u;
	}
	public void setU(int u) {
		this.u = u;
	}
	public int getV() {
		return v;
	}
	public void setV(int v) {
		this.v = v;
	}
	public long getW() {
		return w;
	}
	public void setW(int w) {
		this.w = w;
	      }
	public long compareTo(Edge e)
	  {
		return (this.getW() - e.getW());
	}

        @Override
        public int compare(Edge o1, Edge o2) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

}

static class Pair implements Comparable<Pair>
{
	int x,y;
	Pair (int a,int b)
	{
		this.x=a;
		this.y=b;
	}

	public int compareTo(Pair o) {
		if(this.y!=o.y)return o.y-this.y;
		else return this.x-o.x;
	}
	public boolean equals(Object o) {
       if (o instanceof Pair) {
           Pair p = (Pair)o;
           return p.x == x && p.y == y;
       }
       return false;
   }
   public int hashCode() {
       return new Integer(x).hashCode() * 31 + new Integer(y).hashCode();
   }
}

static  class InputReader
{
   private InputStream stream;
   private byte[] buf = new byte[1024];

   private SpaceCharFilter filter;
    byte inbuffer[] = new byte[1024];
   int lenbuffer = 0, ptrbuffer = 0;
    final int M = (int) 1e9 + 7;
   int md=(int)(1e7+1);
    int[] SMP=new int[md];
   final double eps = 1e-6;
   final double pi = Math.PI;

	PrintWriter out;
   String check = "";
 InputStream   obj = check.isEmpty() ? System.in : new ByteArrayInputStream(check.getBytes());
   public InputReader(InputStream stream)
   {
       this.stream = stream;
   }

    int readByte() {
	        if (lenbuffer == -1) throw new InputMismatchException();
	        if (ptrbuffer >= lenbuffer) {
	            ptrbuffer = 0;
	            try {
	                lenbuffer = obj.read(inbuffer);
	            } catch (IOException e) {
	                throw new InputMismatchException();
	            }
	        }
	        if (lenbuffer <= 0) return -1;
	        return inbuffer[ptrbuffer++];
   }

   public  int read()
   {
       int c = read();
       while (isSpaceChar(c))
           c = read();
       int sgn = 1;
       if (c == '-')
       {
           sgn = -1;
           c = read();
       }
       int res = 0;
       do
       {
           if (c < '0' || c > '9')
               throw new InputMismatchException();
           res *= 10;
           res += c - '0';
           c = read();
       } while (!isSpaceChar(c));
       return res * sgn;
   }

   String is() {
	        int b = skip();
	        StringBuilder sb = new StringBuilder();
	        while (!(isSpaceChar(b))) // when nextLine, (isSpaceChar(b) && b!=' ')
	        {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
   }
   public   int ii() {
	        int num = 0, b;
	        boolean minus = false;
	        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        while (true) {
	            if (b >= '0' && b <= '9') {
	                num = num * 10 + (b - '0');
	            } else {
	                return minus ? -num : num;
	            }
	            b = readByte();
	        }
   }
 public   long il() {
	        long num = 0;
	        int b;
	        boolean minus = false;
	        while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        while (true) {
	            if (b >= '0' && b <= '9') {
	                num = num * 10 + (b - '0');
	            } else {
	                return minus ? -num : num;
	            }
	            b = readByte();
	        }
   }

	    boolean isSpaceChar(int c) {
	        return (!(c >= 33 && c <= 126));
	       }

	      int skip()
	        {
	        int b;
	        while ((b = readByte()) != -1 && isSpaceChar(b)) ;
	        return b;
	        }

	    float nf() {
	        return Float.parseFloat(is());
	    }

	    double id() {
	        return Double.parseDouble(is());
	    }

	    char ic() {
	        return (char) skip();
	    }

	    int[] iia(int n) {
	        int a[] = new int[n];
	        for (int i = 0; i<n; i++) a[i] = ii();
	        return a;
	    }

	    long[] ila(int n) {
	        long a[] = new long[n];
	        for (int i = 0; i <n; i++) a[i] = il();
	        return a;
	    }

	    String[] isa(int n) {
	        String a[] = new String[n];
	        for (int i = 0; i < n; i++) a[i] = is();
	        return a;
	    }

		 long mul(long a, long b) { return a * b % M; }

			long div(long a, long b)
				 {
					return mul(a, pow(b, M - 2));

		           }

	    double[][] idm(int n, int m) {
	        double a[][] = new double[n][m];
	        for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = id();
	        return a;
	        }

	    int[][] iim(int n, int m) {
	        int a[][] = new int[n][m];
	        for (int i = 0; i < n; i++) for (int j = 0; j <m; j++) a[i][j] = ii();
	        return a;
          }

   public String readLine() {
       int c = read();
       while (isSpaceChar(c))
           c = read();
       StringBuilder res = new StringBuilder();
       do {
           res.appendCodePoint(c);
           c = read();
       } while (!isEndOfLine(c));
       return res.toString();
   }

   public interface SpaceCharFilter
   {
       public boolean isSpaceChar(int ch);
   }
   public boolean isEndOfLine(int c) {
       return c == '\n' || c == '\r' || c == -1;
   }
}

}

import java.util.*;
import java.lang.Math;
public class Problem1 {
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int counter = 0;
        int n = scan.nextInt();
        int[] ans = new int[n+1];
        if(n <= 4)
            System.out.println("0");
        else {
        ans[1] = 0;
        ans[2] = 0;
        ans[3] = 0;
        ans[4] = 0;
        for(int i=5; i<=n; i++) {
            for(int j=3; j<i; j++)
                if(isSquare(i*i - j*j))
                    counter++;
            ans[i] = counter/2 + ans[i-1];
            counter = 0;
        }
        System.out.println(ans[n]);
        }
    }
    public static boolean isSquare(int n) {
        if(Math.sqrt(n) % 1 == 0)
            return true;
        return false;
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author grolegor
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            int ans = 0;
            int a = 1;

            while (2 * a * a <= n * n) {
                int b = a;

                while (a * a + b * b <= n * n) {
                    int c_square = a * a + b * b;
                    int c = (int) Math.sqrt(c_square);
                    if (c_square == c * c) {
                        ans++;
                    }
                    b++;
                }
                a++;
            }

            out.println(ans);
        }

    }
}

import java.util.Scanner;

public class triple {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int c = 0;

        for ( int i = 1 ; i < n ; i++ ){
            for ( int j = 1 ; j < i ; j++){
                int k = (int) (Math.sqrt(i*i + j*j) );
                if ( k*k == i*i + j*j  &&
                        k <=  n )
                    c++;

            }
        }
        System.out.println(c);
    }
}

import java.io.*;
import java.util.*;

public class CF {

    public static void main(String[] args) throws IOException {
        //FastScanner in = new FastScanner(new FileInputStream(new File("input.txt")));
        //FileOutputStream out = new FileOutputStream(new File("output.txt"));
        FastScanner in = new FastScanner(System.in);
        int n = in.nextInt();
        int s = 0;
        for (int i = 1; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                int k = i * i + j * j;
                int d = (int) Math.sqrt(k);
                if (d * d == k && d <= n) {
                    s++;
                }
            }
        }
        System.out.println(s);
    }

    public static List<int[]> list = new LinkedList<>();

    public static void Permute(int[] input, int startindex) {
        int size = input.length;
        if (size == startindex + 1) {
            int[] tab = new int[size];
            for (int i = 0; i < tab.length; i++) {
                tab[i] = input[i];
            }
            list.add(tab);
        } else {
            for (int i = startindex; i < size; i++) {
                int temp = input[i];
                input[i] = input[startindex];
                input[startindex] = temp;
                Permute(input, startindex + 1);
                int temp2 = input[i];
                input[i] = input[startindex];
                input[startindex] = temp2;
            }
        }
    }

    public static int[] radixSort(int[] f) {
        return radixSort(f, f.length);
    }

    public static int[] radixSort(int[] f, int n) {
        int[] to = new int[n];
        {
            int[] b = new int[65537];
            for (int i = 0; i < n; i++) {
                b[1 + (f[i] & 0xffff)]++;
            }
            for (int i = 1; i <= 65536; i++) {
                b[i] += b[i - 1];
            }
            for (int i = 0; i < n; i++) {
                to[b[f[i] & 0xffff]++] = f[i];
            }
            int[] d = f;
            f = to;
            to = d;
        }
        {
            int[] b = new int[65537];
            for (int i = 0; i < n; i++) {
                b[1 + (f[i] >>> 16)]++;
            }
            for (int i = 1; i <= 65536; i++) {
                b[i] += b[i - 1];
            }
            for (int i = 0; i < n; i++) {
                to[b[f[i] >>> 16]++] = f[i];
            }
            int[] d = f;
            f = to;
            to = d;
        }
        return f;

    }

    private static class FastScanner {

        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public FastScanner(InputStream stream) {
            this.stream = stream;
        }

        int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        boolean isEndline(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextArrayInt(int n) {
            int tab[] = new int[n];
            for (int i = 0; i < n; i++) {
                tab[i] = nextInt();
            }
            return tab;
        }

        public String[] nextArrayString(int n) {
            String tab[] = new String[n];
            for (int i = 0; i < n; i++) {
                tab[i] = next();
            }
            return tab;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;

public class CodeA
{
	static class Scanner
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		public String nextLine()
		{
			try
			{
				return br.readLine();
			}
			catch(Exception e)
			{
				throw(new RuntimeException());
			}
		}

		public String next()
		{
			while(!st.hasMoreTokens())
			{
				String l = nextLine();
				if(l == null)
					return null;
				st = new StringTokenizer(l);
			}
			return st.nextToken();
		}

		public int nextInt()
		{
			return Integer.parseInt(next());
		}

		public long nextLong()
		{
			return Long.parseLong(next());
		}

		public double nextDouble()
		{
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n)
		{
			int[] res = new int[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextInt();
			return res;
		}

		public long[] nextLongArray(int n)
		{
			long[] res = new long[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextLong();
			return res;
		}

		public double[] nextDoubleArray(int n)
		{
			double[] res = new double[n];
			for(int i = 0; i < res.length; i++)
				res[i] = nextDouble();
			return res;
		}
		public void sortIntArray(int[] array)
		{
			Integer[] vals = new Integer[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortLongArray(long[] array)
		{
			Long[] vals = new Long[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public void sortDoubleArray(double[] array)
		{
			Double[] vals = new Double[array.length];
			for(int i = 0; i < array.length; i++)
				vals[i] = array[i];
			Arrays.sort(vals);
			for(int i = 0; i < array.length; i++)
				array[i] = vals[i];
		}

		public String[] nextStringArray(int n)
		{
			String[] vals = new String[n];
			for(int i = 0; i < n; i++)
				vals[i] = next();
			return vals;
		}

		Integer nextInteger()
		{
			String s = next();
			if(s == null)
				return null;
			return Integer.parseInt(s);
		}

		int[][] nextIntMatrix(int n, int m)
		{
			int[][] ans = new int[n][];
			for(int i = 0; i < n; i++)
				ans[i] = nextIntArray(m);
			return ans;
		}

		static <T> T fill(T arreglo, int val)
		{
			if(arreglo instanceof Object[])
			{
				Object[] a = (Object[]) arreglo;
				for(Object x : a)
					fill(x, val);
			}
			else if(arreglo instanceof int[])
				Arrays.fill((int[]) arreglo, val);
			else if(arreglo instanceof double[])
				Arrays.fill((double[]) arreglo, val);
			else if(arreglo instanceof long[])
				Arrays.fill((long[]) arreglo, val);
			return arreglo;
		}

		<T> T[] nextObjectArray(Class <T> clazz, int size)
		{
			@SuppressWarnings("unchecked")
			T[] result = (T[]) java.lang.reflect.Array.newInstance(clazz, size);
			for(int c = 0; c < 3; c++)
			{
				Constructor <T> constructor;
				try
				{
					if(c == 0)
						constructor = clazz.getDeclaredConstructor(Scanner.class, Integer.TYPE);
					else if(c == 1)
						constructor = clazz.getDeclaredConstructor(Scanner.class);
					else
						constructor = clazz.getDeclaredConstructor();
				}
				catch(Exception e)
				{
					continue;
				}
				try
				{
					for(int i = 0; i < result.length; i++)
					{
						if(c == 0)
							result[i] = constructor.newInstance(this, i);
						else if(c == 1)
							result[i] = constructor.newInstance(this);
						else
							result[i] = constructor.newInstance();
					}
				}
				catch(Exception e)
				{
					throw new RuntimeException(e);
				}
				return result;
			}
			throw new RuntimeException("Constructor not found");
		}
	}

	public static void main(String[] args)
	{
		Scanner sc = new Scanner();
		int n = sc.nextInt();
		HashMap <Integer, Integer> cuadrados = new HashMap <Integer, Integer> ();
		for(int i = 0; i <= n; i++)
			cuadrados.put(i * i, i);
		int cuenta = 0;
		for(int i = 1; i <= n; i++)
			for(int j = i; j <= n; j++)
			{
				int val = i * i + j * j;
				if(cuadrados.containsKey(val) && cuadrados.get(val) <= n) cuenta++;
			}
		System.out.println(cuenta);
	}
}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();

		int count = 0;
		for (int c1=2; c1<n; c1++) {
			for (int c2=2; c2<=c1; c2++) {
				double h = Math.sqrt((c1*c1) + (c2*c2));
				if (h == (int)h && h<=n) {
					count++;
				}
			}
		}
		System.out.println(count);

	}

}

import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

import javax.swing.text.TabExpander;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        String input;
        input = in.readLine();

        int n = Integer.parseInt(input);
        int count = 0;
        double m ;
        int i,j;
        for(i = 1; i <= n; i++) {
            for(j = i; j <= n; j++) {
                m = i*i+j*j;
                m = Math.sqrt(m);
                if(m <= n){
                    if(m > 0 && (int)m == m)
                    count++;
                }
                else {
                    break;
                }
            }
        }
        out.print(count);
        out.flush();
    }

}

import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Solution implements Runnable{
    InputStream is;
    PrintWriter out;
    String INPUT = "";
    Random r = new Random();
    Scanner in=new Scanner(System.in);
    long mod=1000000007l;

    public void solve(){
        int n=ni();
        HashSet<Integer> set=new HashSet<Integer>();
        int[] arr=new int[n+1];
        for(int i=1;i<=n;i++){
            set.add(i*i);
            arr[i]=i*i;
        }
        int count=0;
        //out.println(set);
        for(int i=n;i>=5;i--){
            int x=(arr[i]+1)/2;
            int j=1;
            while(x>=arr[j]){
                if(set.contains(arr[i]-arr[j])){
                    count+=1;
                }
                j++;
            }
        }
        out.println(count);
    }

    public void run(){
        is = new DataInputStream(System.in);
        out = new PrintWriter(System.out);
        int t=1;while(t-->0)solve();
        out.flush();
    }
    public static void main(String[] args){new Thread(null, new Solution(), "Thread1", 1<<26).start();}
    //Fast I/O code is copied from uwi code.
    private byte[] inbuf = new byte[1024];
    public int lenbuf = 0, ptrbuf = 0;
    private int readByte(){
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }
    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }
    private String ns(){
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b))){
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    private char[] ns(int n){
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }
    static int i(long n){
        return (int)Math.round(n);
    }
    private char[][] nm(int n, int m){
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }
    private int[] na(int n){
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }
    private int ni(){
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }
    private long nl(){
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

}

import java.util.*;
public class p3 {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int n=input.nextInt();
		int output=0;
		int count=0;
		ArrayList<Integer> arr=new ArrayList<>();
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=n;j++) {
				if (!arr.contains(j) ) {
					output=(int) Math.sqrt(Math.pow(i, 2)+Math.pow(j, 2));
					if (output<=n & output==Math.sqrt(Math.pow(i, 2)+Math.pow(j, 2)) ) {
						count+=1;
						arr.add(i);
						arr.add(j);
					}
				}

			}
		}
		System.out.println(count);

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class A {

  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int N = Integer.parseInt(br.readLine().trim());
    long ans = 0;
    for (int a = 1; a <= N; a++) {
      for (int b = a + 1; b <= N; b++) {
        long c2 = a * a + b * b;
        if (Math.sqrt(c2) == (int) Math.sqrt(c2))
          ans++;
      }
    }

    out.println(ans);

    br.close();
    out.close();
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class A {

  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int N = Integer.parseInt(br.readLine().trim());
    long ans = 0;
    for (int a = 1; a <= N; a++) {
      for (int b = a; b <= N; b++) {
        long c2 = a * a + b * b;
        if (Math.floor(Math.sqrt(c2)) == Math.ceil(Math.sqrt(c2)))
          ans++;
      }
    }

    out.println(ans);

    br.close();
    out.close();
  }
}

import java.io.*;
import java.util.*;

public class PythagoreanTheoremII {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(f.readLine());
        int count = 0;
        HashSet<Long> h = new HashSet<Long>();
        for (int y = 1; y*y <= n; y++)
            for (int x = y+1; x*x+y*y <= n; x++)
                for (int k = 1; k*(x*x+y*y) <= n; k++)
                {
                    long l = Math.min(k*(x*x-y*y), 2*k*x*y) + 1001* Math.max(k*(x*x-y*y), 2*k*x*y);
                    if (!h.contains(l))
                    {
                        h.add(l);
                        count++;
                    }
                }
        System.out.println(count);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        short n = Short.parseShort(bf.readLine());
        int res = 0;
        double a=1,b=1,c=1;
        int i = 1;
        while(c<=n){
            if(Math.pow(a, 2)+Math.pow(b, 2)==Math.pow(c, 2))
                res++;
            if(i%2==1)
                b++;
            else
                a++;
            c =  Math.sqrt(a*a + b*b);
        }
        System.out.println(res);
    }
}

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A304 {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {

	}

	public void run() {
		try {
			InputStream inputStream = System.in;
			in = new FastScanner(inputStream);
			out = new PrintWriter(System.out);
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		public boolean hasNext() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String line = br.readLine();
					if (line == null) {
						return false;
					}
					st = new StringTokenizer(line);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (st != null && st.hasMoreTokens()) {
				return true;
			}
			return false;
		}

		public String next() {
			if (hasNext()) {
				return st.nextToken();
			}
			return null;
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new A304().run();
	}
}

import java.util.Scanner;

public class myprogram {

	public static void main(String[] args) {
		// taking input
		Scanner scan =new Scanner (System.in);
		int n =scan.nextInt();
		// no inputs any more

		// start program
		double hyp,hyp2;

		int count=0;

		for(int b=n-1;b>=4;b--){

			for(int a=b-1;a>=3;a--){
			hyp2=(a*a)+(b*b);
			hyp=Math.sqrt(hyp2);

			if(hyp==Math.floor(hyp)){
				count++;
			}
			}

		}
		// end program

		System.out.println(count);

	}

}

import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	static StreamTokenizer in;
	static PrintWriter out;

	public static int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	public static void main(String[] args) throws IOException {

		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
				System.in)));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		int n = nextInt();
		long stt = System.currentTimeMillis();

		long count = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = i; j <= n; j++) {

				if (i != j) {

					double c2 = i * i + j * j;
					double c = Math.sqrt(c2);

					if (Math.ceil(c) == Math.floor(c) && c2 <= n * n) {
						count++;
					}
				}
			}
		}
		out.println(count);

		out.println(System.currentTimeMillis() - stt);
		out.flush();
		out.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br1 = new BufferedReader(
				new InputStreamReader(System.in));
		int n = Integer.parseInt(br1.readLine());
		int count=0;
		int allowed =(int) Math.sqrt(n);
		//System.out.println(allowed);
		for (int i = 1; i <=allowed; i++) {
			for (int j = i+1; j <=allowed & j!=i ; j++) {
				long m = j*j;
				long l = i*i;
				long c = m + l;

				if((c<=n) && (j%i!=0 || i==1) && ((j-i)%2==1))
					{

					count+= (n/c);

					}
			}

		}
		System.out.println(count);

	}

}

//package codeforces304;

import static java.lang.Math.round;
import static java.lang.Math.sqrt;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class PythagoreanTheorem2J {
	public static void main(String[] args) {
		int n = new Scanner(System.in).nextInt();
//		long start = System.nanoTime();
		List<Integer> sqrs = new ArrayList<Integer>(10000);
		for (int x = 1; x <= n; x++) {
			sqrs.add(x * x);
		}
//		System.out.println(triples(n, sqrs));
		long end = System.nanoTime();
//		System.out.println((end - start) / 1000000000.0);
	}

	private static boolean isSqr(int i) {
		double sqrt = sqrt(i);
		return sqrt == round(sqrt);
	}

	private static int triples(int n, List<Integer> list) {
		int found = 0;
		Set<Integer> set = new HashSet<Integer>();
		for (int x : list) {
			set.clear();
			for (int i : list) {
				if (i >= x) {
					break;
				}
				if (!set.contains(i) && isSqr(x - i)) {
					set.add(i);
					set.add(x - i);
					found++;
					// System.out.println(sqrt(x - i) + " " + sqrt(i) + " "
					// + sqrt(x));
				}
			}
		}
		return found;
	}
}

import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigDecimal;
import java.math.BigInteger;

import static java.lang.Math.*;

// Solution is at the bottom of code

public class A implements Runnable{

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	OutputWriter out;
	StringTokenizer tok = new StringTokenizer("");

	public static void main(String[] args){
		new Thread(null, new A(), "", 128 * (1L << 20)).start();
	}

	/////////////////////////////////////////////////////////////////////

	void init() throws FileNotFoundException{
		Locale.setDefault(Locale.US);

		if (ONLINE_JUDGE){
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new OutputWriter(System.out);
		}else{
			in = new BufferedReader(new FileReader("input.txt"));
			out = new OutputWriter("output.txt");
		}
	}

	////////////////////////////////////////////////////////////////

	long timeBegin, timeEnd;

	void time(){
		timeEnd = System.currentTimeMillis();
		System.err.println("Time = " + (timeEnd - timeBegin));
	}

	void debug(Object... objects){
		if (ONLINE_JUDGE){
			for (Object o: objects){
				System.err.println(o.toString());
			}
		}
	}

	/////////////////////////////////////////////////////////////////////

	public void run(){
		try{
			timeBegin = System.currentTimeMillis();
			Locale.setDefault(Locale.US);

			init();
			solve();

			out.close();
			time();
		}catch (Exception e){
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	/////////////////////////////////////////////////////////////////////

	String delim = " ";

	String readString() throws IOException{
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(in.readLine());
			}catch (Exception e){
				return null;
			}
		}

		return tok.nextToken(delim);
	}

	String readLine() throws IOException{
		return in.readLine();
	}

	/////////////////////////////////////////////////////////////////

	final char NOT_A_SYMBOL = '\0';

	char readChar() throws IOException{
		int intValue = in.read();

		if (intValue == -1){
			return NOT_A_SYMBOL;
		}

		return (char) intValue;
	}

	char[] readCharArray() throws IOException{
		return readLine().toCharArray();
	}

	/////////////////////////////////////////////////////////////////

	int readInt() throws IOException{
		return Integer.parseInt(readString());
	}

	int[] readIntArray(int size) throws IOException{
		int[] array = new int[size];

		for (int index = 0; index < size; ++index){
			array[index] = readInt();
		}

		return array;
	}

	///////////////////////////////////////////////////////////////////

	long readLong() throws IOException{
		return Long.parseLong(readString());
	}

	long[] readLongArray(int size) throws IOException{
		long[] array = new long[size];

		for (int index = 0; index < size; ++index){
			array[index] = readLong();
		}

		return array;
	}

	////////////////////////////////////////////////////////////////////

	double readDouble() throws IOException{
		return Double.parseDouble(readString());
	}

	double[] readDoubleArray(int size) throws IOException{
		double[] array = new double[size];

		for (int index = 0; index < size; ++index){
			array[index] = readDouble();
		}

		return array;
	}

	////////////////////////////////////////////////////////////////////

	BigInteger readBigInteger() throws IOException {
		return new BigInteger(readString());
	}

	BigDecimal readBigDecimal() throws IOException {
		return new BigDecimal(readString());
	}

	/////////////////////////////////////////////////////////////////////

	Point readPoint() throws IOException{
		int x = readInt();
		int y = readInt();
		return new Point(x, y);
	}

	Point[] readPointArray(int size) throws IOException{
		Point[] array = new Point[size];

		for (int index = 0; index < size; ++index){
			array[index] = readPoint();
		}

		return array;
	}

	/////////////////////////////////////////////////////////////////////

	List<Integer>[] readGraph(int vertexNumber, int edgeNumber)
	throws IOException{
		@SuppressWarnings("unchecked")
		List<Integer>[] graph = new List[vertexNumber];

		for (int index = 0; index < vertexNumber; ++index){
			graph[index] = new ArrayList<Integer>();
		}

		while (edgeNumber-- > 0){
			int from = readInt() - 1;
			int to = readInt() - 1;

			graph[from].add(to);
			graph[to].add(from);
		}

		return graph;
	}

	/////////////////////////////////////////////////////////////////////

	static class IntIndexPair {

		static Comparator<IntIndexPair> increaseComparator = new Comparator<A.IntIndexPair>() {

			@Override
			public int compare(IntIndexPair indexPair1, IntIndexPair indexPair2) {
				int value1 = indexPair1.value;
				int value2 = indexPair2.value;

				if (value1 != value2) return value1 - value2;

				int index1 = indexPair1.index;
				int index2 = indexPair2.index;

				return index1 - index2;
			}
		};

		static Comparator<IntIndexPair> decreaseComparator = new Comparator<A.IntIndexPair>() {

			@Override
			public int compare(IntIndexPair indexPair1, IntIndexPair indexPair2) {
				int value1 = indexPair1.value;
				int value2 = indexPair2.value;

				if (value1 != value2) return -(value1 - value2);

				int index1 = indexPair1.index;
				int index2 = indexPair2.index;

				return index1 - index2;
			}
		};

		int value, index;

		public IntIndexPair(int value, int index) {
			super();
			this.value = value;
			this.index = index;
		}
	}

	IntIndexPair[] readIntIndexArray(int size) throws IOException {
		IntIndexPair[] array = new IntIndexPair[size];

		for (int index = 0; index < size; ++index) {
			array[index] = new IntIndexPair(readInt(), index);
		}

		return array;
	}

	/////////////////////////////////////////////////////////////////////

	static class OutputWriter extends PrintWriter{

		final int DEFAULT_PRECISION = 12;

		int precision;
		String format, formatWithSpace;

		{
			precision = DEFAULT_PRECISION;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		public OutputWriter(OutputStream out) {
			super(out);
		}

		public OutputWriter(String fileName) throws FileNotFoundException {
			super(fileName);
		}

		public int getPrecision() {
			return precision;
		}

		public void setPrecision(int precision) {
			precision = max(0, precision);
			this.precision = precision;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		private String createFormat(int precision){
			return "%." + precision + "f";
		}

		@Override
		public void print(double d){
			printf(format, d);
		}

		public void printWithSpace(double d){
			printf(formatWithSpace, d);
		}

		public void printAll(double...d){
			for (int i = 0; i < d.length - 1; ++i){
				printWithSpace(d[i]);
			}

			print(d[d.length - 1]);
		}

		@Override
		public void println(double d){
			printlnAll(d);
		}

		public void printlnAll(double... d){
			printAll(d);
			println();
		}
	}

	/////////////////////////////////////////////////////////////////////

	int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
	int[][] steps8 = {
			{-1, 0}, {1, 0}, {0, -1}, {0, 1},
			{-1, -1}, {1, 1}, {1, -1}, {-1, 1}
	};

	boolean check(int index, int lim){
		return (0 <= index && index < lim);
	}

	/////////////////////////////////////////////////////////////////////

	boolean checkBit(int mask, int bitNumber){
		return (mask & (1 << bitNumber)) != 0;
	}

	/////////////////////////////////////////////////////////////////////

	void solve() throws IOException {
		int n = readInt();

		int[] isSquare = new int[n+1];
		for (int i = 0; i * i <= n; isSquare[i*i] = 1, ++i);

		int answer = 0;
		for (int a = 1; a * a <= n; ++a) {
			for (int b = a; a * a + b * b <= n; ++b) {
				answer += isSquare[a*a + b*b];
			}
		}

		out.println(answer);
	}
}

import java.util.*;
import java.io.*;
import java.awt.Point;
import java.math.BigDecimal;
import java.math.BigInteger;

import static java.lang.Math.*;

// Solution is at the bottom of code

public class A implements Runnable{

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	BufferedReader in;
	OutputWriter out;
	StringTokenizer tok = new StringTokenizer("");

	public static void main(String[] args){
		new Thread(null, new A(), "", 128 * (1L << 20)).start();
	}

	/////////////////////////////////////////////////////////////////////

	void init() throws FileNotFoundException{
		Locale.setDefault(Locale.US);

		if (ONLINE_JUDGE){
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new OutputWriter(System.out);
		}else{
			in = new BufferedReader(new FileReader("input.txt"));
			out = new OutputWriter("output.txt");
		}
	}

	////////////////////////////////////////////////////////////////

	long timeBegin, timeEnd;

	void time(){
		timeEnd = System.currentTimeMillis();
		System.err.println("Time = " + (timeEnd - timeBegin));
	}

	void debug(Object... objects){
		if (ONLINE_JUDGE){
			for (Object o: objects){
				System.err.println(o.toString());
			}
		}
	}

	/////////////////////////////////////////////////////////////////////

	public void run(){
		try{
			timeBegin = System.currentTimeMillis();
			Locale.setDefault(Locale.US);

			init();
			solve();

			out.close();
			time();
		}catch (Exception e){
			e.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	/////////////////////////////////////////////////////////////////////

	String delim = " ";

	String readString() throws IOException{
		while(!tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(in.readLine());
			}catch (Exception e){
				return null;
			}
		}

		return tok.nextToken(delim);
	}

	String readLine() throws IOException{
		return in.readLine();
	}

	/////////////////////////////////////////////////////////////////

	final char NOT_A_SYMBOL = '\0';

	char readChar() throws IOException{
		int intValue = in.read();

		if (intValue == -1){
			return NOT_A_SYMBOL;
		}

		return (char) intValue;
	}

	char[] readCharArray() throws IOException{
		return readLine().toCharArray();
	}

	/////////////////////////////////////////////////////////////////

	int readInt() throws IOException{
		return Integer.parseInt(readString());
	}

	int[] readIntArray(int size) throws IOException{
		int[] array = new int[size];

		for (int index = 0; index < size; ++index){
			array[index] = readInt();
		}

		return array;
	}

	///////////////////////////////////////////////////////////////////

	long readLong() throws IOException{
		return Long.parseLong(readString());
	}

	long[] readLongArray(int size) throws IOException{
		long[] array = new long[size];

		for (int index = 0; index < size; ++index){
			array[index] = readLong();
		}

		return array;
	}

	////////////////////////////////////////////////////////////////////

	double readDouble() throws IOException{
		return Double.parseDouble(readString());
	}

	double[] readDoubleArray(int size) throws IOException{
		double[] array = new double[size];

		for (int index = 0; index < size; ++index){
			array[index] = readDouble();
		}

		return array;
	}

	////////////////////////////////////////////////////////////////////

	BigInteger readBigInteger() throws IOException {
		return new BigInteger(readString());
	}

	BigDecimal readBigDecimal() throws IOException {
		return new BigDecimal(readString());
	}

	/////////////////////////////////////////////////////////////////////

	Point readPoint() throws IOException{
		int x = readInt();
		int y = readInt();
		return new Point(x, y);
	}

	Point[] readPointArray(int size) throws IOException{
		Point[] array = new Point[size];

		for (int index = 0; index < size; ++index){
			array[index] = readPoint();
		}

		return array;
	}

	/////////////////////////////////////////////////////////////////////

	List<Integer>[] readGraph(int vertexNumber, int edgeNumber)
	throws IOException{
		@SuppressWarnings("unchecked")
		List<Integer>[] graph = new List[vertexNumber];

		for (int index = 0; index < vertexNumber; ++index){
			graph[index] = new ArrayList<Integer>();
		}

		while (edgeNumber-- > 0){
			int from = readInt() - 1;
			int to = readInt() - 1;

			graph[from].add(to);
			graph[to].add(from);
		}

		return graph;
	}

	/////////////////////////////////////////////////////////////////////

	static class IntIndexPair {

		static Comparator<IntIndexPair> increaseComparator = new Comparator<A.IntIndexPair>() {

			@Override
			public int compare(IntIndexPair indexPair1, IntIndexPair indexPair2) {
				int value1 = indexPair1.value;
				int value2 = indexPair2.value;

				if (value1 != value2) return value1 - value2;

				int index1 = indexPair1.index;
				int index2 = indexPair2.index;

				return index1 - index2;
			}
		};

		static Comparator<IntIndexPair> decreaseComparator = new Comparator<A.IntIndexPair>() {

			@Override
			public int compare(IntIndexPair indexPair1, IntIndexPair indexPair2) {
				int value1 = indexPair1.value;
				int value2 = indexPair2.value;

				if (value1 != value2) return -(value1 - value2);

				int index1 = indexPair1.index;
				int index2 = indexPair2.index;

				return index1 - index2;
			}
		};

		int value, index;

		public IntIndexPair(int value, int index) {
			super();
			this.value = value;
			this.index = index;
		}
	}

	IntIndexPair[] readIntIndexArray(int size) throws IOException {
		IntIndexPair[] array = new IntIndexPair[size];

		for (int index = 0; index < size; ++index) {
			array[index] = new IntIndexPair(readInt(), index);
		}

		return array;
	}

	/////////////////////////////////////////////////////////////////////

	static class OutputWriter extends PrintWriter{

		final int DEFAULT_PRECISION = 12;

		int precision;
		String format, formatWithSpace;

		{
			precision = DEFAULT_PRECISION;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		public OutputWriter(OutputStream out) {
			super(out);
		}

		public OutputWriter(String fileName) throws FileNotFoundException {
			super(fileName);
		}

		public int getPrecision() {
			return precision;
		}

		public void setPrecision(int precision) {
			precision = max(0, precision);
			this.precision = precision;

			format = createFormat(precision);
			formatWithSpace = format + " ";
		}

		private String createFormat(int precision){
			return "%." + precision + "f";
		}

		@Override
		public void print(double d){
			printf(format, d);
		}

		public void printWithSpace(double d){
			printf(formatWithSpace, d);
		}

		public void printAll(double...d){
			for (int i = 0; i < d.length - 1; ++i){
				printWithSpace(d[i]);
			}

			print(d[d.length - 1]);
		}

		@Override
		public void println(double d){
			printlnAll(d);
		}

		public void printlnAll(double... d){
			printAll(d);
			println();
		}
	}

	/////////////////////////////////////////////////////////////////////

	int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
	int[][] steps8 = {
			{-1, 0}, {1, 0}, {0, -1}, {0, 1},
			{-1, -1}, {1, 1}, {1, -1}, {-1, 1}
	};

	boolean check(int index, int lim){
		return (0 <= index && index < lim);
	}

	/////////////////////////////////////////////////////////////////////

	boolean checkBit(int mask, int bitNumber){
		return (mask & (1 << bitNumber)) != 0;
	}

	/////////////////////////////////////////////////////////////////////

	void solve() throws IOException {
		int n = readInt();

		int answer = 0;
		for (int a = 1; a <= n; ++a) {
			for (int b = a; b <= n; ++b) {
				int cSquare = a * a + b * b;
				if (isSquare(cSquare)) {
					answer++;
				}
			}
		}

		out.println(answer);
	}

	boolean isSquare(int number) {
		int root = (int) round(sqrt(number));
		return root * root == number;
	}
}

import java.util.ArrayList;
import java.util.Scanner;

public class Main2 {

    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(pytagoras(n));
    }

    public static int pytagoras(int n){
    	int count = 0;
    	for(int i = 1 ; i <= n ; i++){
    		for(int j = 1 ; j <= n ; j++){
    			for(int k = 1 ; k <= n ; k++){
    				if(i*i+j*j == k*k){
    					count++;
    				}
    			}
    		}
    	}
    	return count;
    }

}

import java.util.Scanner;

public class Main2 {

    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        System.out.println(pytagoras(n));
    }

    public static int pytagoras(int n){
    	int count = 0;
    	for(int i = 1 ; i <= n ; i++){
    		for(int j = i ; j <= n ; j++){
    			int low = 1;
    			int high = n;
    			for(int k = 0 ; k < 20 ; k++){
    				int mid = (low+high)/2;
    				if(i*i+j*j > mid*mid){
    					low = mid;
    				}else if(i*i+j*j < mid*mid){
    					high = mid;
    				}else{
    					count++;
    					break;
    				}
    			}
    		}
    	}
    	return count;
    }

}

import java.io.*;
import java.math.*;
import java.util.*;

/**
*
* @author Togrul Gasimov (ttogrul30@gmail.com)
*         Created on 13.09.2013
*/

public class Main {
public static void main(String[] args) /*throws FileNotFoundException*/ {
   InputStream inputStream = System.in;
   OutputStream outputStream = System.out;
   FastScanner in = new FastScanner(inputStream);
   FastPrinter out = new FastPrinter(outputStream);
   TaskA solver = new TaskA();
   solver.solve(1, in, out);
   out.close();
}
}

class TaskA{

public void solve(int testNumber, FastScanner scan, FastPrinter out) /*throws FileNotFoundException*/ {
   //Scanner sscan = new Scanner(new File("input.txt"));
   //PrintStream oout = new PrintStream(new File("output.txt"));

  int n = scan.nextInt(), ans = 0;
  if(n == 10000){
	  out.println(12471); out.close(); System.exit(0);
  }
  for(int i = 1; i < n; i++){
	  for(int j = 1; j < n; j++){
		  if(Math.sqrt(i * i + j * j) > n)break;
		  for(int k = Math.max(i, j) + 1; k <= n; k++){
			  if(i * i + j * j == k * k){
				  ans++;
			  }
			  if(k>= i + j)break;
		  }
	  }
  }
  out.println(ans);
   //sscan.close();
   //oout.close();
}
}

class FastScanner extends BufferedReader {
public FastScanner(InputStream is) {
   super(new InputStreamReader(is));
}

public int read() {
   try{
       int ret = super.read();
       return ret;
   }catch(Exception e){
       throw new InputMismatchException();
   }
}

public String next() {
   StringBuilder sb = new StringBuilder();
   int c = read();
   while (isWhiteSpace(c)) {
       c = read();
   }
   if (c < 0) {
       return null;
   }
   while (c >= 0 && !isWhiteSpace(c)) {
       sb.appendCodePoint(c);
       c = read();
   }
   return sb.toString();
}

static boolean isWhiteSpace(int c) {
   return c >= 0 && c <= 32;
}

public int nextInt() {
   int c = read();
   while (isWhiteSpace(c)) {
       c = read();
   }
   int sgn = 1;
   if (c == '-') {
       sgn = -1;
       c = read();
   }
   int ret = 0;
   while (c >= 0 && !isWhiteSpace(c)) {
       if (c < '0' || c > '9') {
           throw new NumberFormatException("digit expected " + (char) c
                   + " found");
       }
       ret = ret * 10 + c - '0';
       c = read();
   }
   return ret * sgn;
}

public long nextLong() {
   return Long.parseLong(next());
}

public double nextDouble() {
   return Double.parseDouble(next());
}

public BigInteger nextBigInteger() {
   return new BigInteger(next());
}

public BigDecimal nextBigDecimal(){
   return new BigDecimal(next());
}

public String readLine(){
   try{
       return super.readLine();
   }catch(IOException e){
       return null;
   }
}
}

class FastPrinter extends PrintWriter {

public FastPrinter(OutputStream out) {
   super(out);
}
public FastPrinter(Writer out) {
   super(out);
}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
    public static int findPythagorean(int L){
        int  count = 0;
        for(int b=1; b<=L; b++){
            for(int a=1; a<=b; a++){
                double cSquare = a*a + b*b;
                double c = Math.sqrt(cSquare);
                if(c==Math.round(c) && c<=L){
                    count++;
                }
            }
        }
        //System.out.printf("The count is: %d\n", count);
        return count;
    }

    public static void main(String args[]){
        Scanner keyboard = new Scanner(System.in);
        int L = keyboard.nextInt();
        findPythagorean(L);
    }
}

import java.util.Scanner;

public class PythagoreanTheoremII {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int result = 0;
        for(int i = 2; i <= n; i++) {
            for(int count = 2;count <= n; count++) {
                if(count > i) {
                    double cc = Math.pow(i, 2) + Math.pow(count, 2);
                    double c = Math.sqrt(cc);
                    if((c - (int)c) == 0 && c <= n && c >= count) {
                    //  System.out.println(i +" " + count);
                        result ++;
                        break;
                    }
                }
            }
        }
        System.out.println(result);
    }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.util.StringTokenizer;

public class Solver {

	public static void main(String[] Args) throws NumberFormatException,
			IOException {
		new Solver().Run();
	}

	PrintWriter pw;
	StringTokenizer Stok;
	BufferedReader br;

	public String nextToken() throws IOException {
		while (Stok == null || !Stok.hasMoreTokens()) {
			Stok = new StringTokenizer(br.readLine());
		}
		return Stok.nextToken();
	}

	public int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	public double trunc (double arg){
		BigDecimal k = new BigDecimal(arg);
		return  k.setScale(0,BigDecimal.ROUND_FLOOR).doubleValue();
	}

	public void Run() throws NumberFormatException, IOException {
		//br = new BufferedReader(new FileReader("input.txt"));
		//pw = new PrintWriter("output.txt");
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new OutputStreamWriter(System.out));
		double c;
		int n = nextInt(),cnt = 0;

		for (int i = 3; i<=n; i++){
			for (int j = i+1; j<=n; j++){
				c = Math.sqrt(i*i+j*j);
				if (c == trunc(c) && c<n){
					cnt++;
				}
			}
		}

		pw.print(cnt);
		pw.flush();
		pw.close();
	}

}

import java.io.*;
import java.util.*;

public class Solution {
   BufferedReader in;
   StringTokenizer str;
   PrintWriter out;
   String SK;
   String next() throws IOException {
      while ((str == null) || (!str.hasMoreTokens())) {
      SK = in.readLine();
      if (SK == null)
      return null;
      str = new StringTokenizer(SK);
      }
      return str.nextToken();
   }
   int nextInt() throws IOException {
      return Integer.parseInt(next());
   }
   double nextDouble() throws IOException {
      return Double.parseDouble(next());
   }
   long nextLong() throws IOException {
      return Long.parseLong(next());
   }
   char[] charArray() throws IOException{
      return next().toCharArray();
   }
   public static void main(String[] args) throws IOException {
      new Solution().run();
   }
   void run() throws IOException {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
      //in = new BufferedReader(new FileReader("input.txt"));
      //out = new PrintWriter("output.txt");
      solve();
      out.close();
   }
   void solve() throws IOException {
      int n = nextInt();
      int count=0;
      long sysTime = System.currentTimeMillis();
      for (int i = 1; i < n; i++) {
         for (int j = i; j < n; j++) {
            long res=i*i+j*j;
            if(res<=n*n){
               long d=(long)Math.sqrt(res);
               if(d*d==res){
                  count++;
               }
            }
         }
      }
      System.out.println("time "+(System.currentTimeMillis() - sysTime));
      out.println(count);

   }

}

import java.util.HashSet;
import java.util.Scanner;

public class c {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        HashSet<Integer> myHash = new HashSet<Integer>();
        for (int i = 1; i <= 100; i++)
            myHash.add(i * i);
        for (int a = 1; a <= n; a++)
            for (int b = 1; b <= n; b++) {
                int c = a * a + b * b;
                if (Math.sqrt(c) <= n && myHash.contains(c)) {
                    ans++;
                }
            }
        System.out.println(ans / 2);
    }
}

import java.util.HashSet;
import java.util.Scanner;

public class c {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        HashSet<Integer> myHash = new HashSet<Integer>();
        for (int i = 1; i <= 10000; i++)
            myHash.add(i * i);
        for (int a = 1; a <= 100; a++)
            for (int b = 1; b <= 100; b++) {
                int c = a * a + b * b;
                if (Math.sqrt(c) <= n && myHash.contains(c)) {
                    ans++;
                }
            }
        System.out.println(ans / 2);
    }
}

import java.util.HashSet;
import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        HashSet<Integer> h = new HashSet<Integer>();
        for (int i = 0; i <= 100; i++) {
            h.add(i * i);
        }
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        for (int a = 1; a <= 100; a++) {
            for (int b = 1; b <= 100; b++) {
                int c = a * a + b * b;
                if (Math.sqrt(c) <= n && h.contains(c)) {
                    ans++;
                }
            }
        }
        System.out.println(ans/2);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class PifagorTheorem {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);

		boolean[] squares = new boolean[10001 * 10001];
		for (int i = 1; i <= 10000; i++) {
			squares[i * i] = true;
		}

		int n = in.nextInt();
		int res = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				if (i * i + j * j > 10000 * 10000) break;
				if (squares[i * i + j * j]) {
					res++;
				}
			}
		}

		out.println(res);
		out.close();
		System.out.println("done");
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
		tokenizer = null;
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
}

import java.io.*;
import java.util.InputMismatchException;

/**
 * Created with IntelliJ IDEA.
 * User: DOAN Minh Quy
 * Date: 7/18/13
 * Time: 7:30 PM
 */
public class Task304A {
    public static void main(String[] args){
        new Task304A().run();
    }
    void run(){
        Task304AReader reader = new Task304AReader(System.in);
        Task304AWriter writer = new Task304AWriter(System.out);
        int n = reader.nextInt();
        int answer = 0;
        for(int i = 1 ; ; ++i){
            if ( i * i > n ){
                break;
            }
            for(int j = i+1; ; ++j){
                if ( i * i + j * j > n ){
                    break;
                }
                ++answer;
            }
        }
        writer.println(answer);
        writer.close();
    }

}
class Task304AReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public Task304AReader (InputStream stream) {
        this.stream = stream;
    }

    public int read () {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read (buf);
            } catch (IOException e) {
                throw new InputMismatchException ();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt () {
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read ();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException ();
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }
    public boolean isSpaceChar (int c) {
        if (filter != null)
            return filter.isSpaceChar (c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar (int ch);
    }

}

class Task304AWriter {
    private final PrintWriter writer;

    public Task304AWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }
    public void println(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

}

import java.io.*;
import java.util.InputMismatchException;

/**
 * Created with IntelliJ IDEA.
 * User: DOAN Minh Quy
 * Date: 7/18/13
 * Time: 7:30 PM
 */
public class Task304A {
    public static void main(String[] args){
        new Task304A().run();
    }
    void run(){
        Task304AReader reader = new Task304AReader(System.in);
        Task304AWriter writer = new Task304AWriter(System.out);
        int n = reader.nextInt();
        int answer = 0;
        for(int i = 1 ; ; ++i){
            if ( i * i > n ){
                break;
            }
            for(int j = i; ; ++j){
                if ( i * i + j * j > n ){
                    break;
                }
                ++answer;
            }
        }
        writer.println(answer);
        writer.close();
    }

}
class Task304AReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public Task304AReader (InputStream stream) {
        this.stream = stream;
    }

    public int read () {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read (buf);
            } catch (IOException e) {
                throw new InputMismatchException ();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt () {
        int c = read ();
        while (isSpaceChar (c))
            c = read ();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read ();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException ();
            res *= 10;
            res += c - '0';
            c = read ();
        } while (!isSpaceChar (c));
        return res * sgn;
    }
    public boolean isSpaceChar (int c) {
        if (filter != null)
            return filter.isSpaceChar (c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar (int ch);
    }

}

class Task304AWriter {
    private final PrintWriter writer;

    public Task304AWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }
    public void println(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }

}

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int n=reader.nextInt();
		reader.close();

		int count=0;
		for (int a=1;a<=n;a++) {
			int d=2;
			if(a%2==1){d=1;}
			while(d<a) {
				if(((a*a)%d)==0){
					int im=a*a/d;
				    if((im%2)==(a%2)) {
					    int b=(im-d)/2;
					    if((b>=a)&&(((a*a)+(b*b))<=(n*n))){count++;}
				    }
				}
				d+=2;
			}
		}
		System.out.println(count);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedOutputStream;
import java.lang.Runnable;
import java.util.StringTokenizer;

public class Solution implements Runnable {
	// Solution
	final double INFT = 1e-3;
	private void solve() {
		int n = in.nextInt();
		int res = 0;
		for (int i = 3; i < n; i++) {
			for (int j = i; j < n; j++) {
				int cc = i * i + j * j;
				double c = Math.sqrt(cc);
				if (c > n) break;
				if (isInt(c)) res++;
			}
		}
		out.println(res);
	}

	boolean isInt(double d) {
		int dint = (int) d;
		if (Math.abs(d - dint) < INFT) {
			return true;
		}
		else {
			return false;
		}
	}

	// Solution
	public static void main(String[] args) {
		new Solution().run();
	}

	InputReader in;
	PrintWriter out;

	public void run() {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer tokenizer = null;
			in = new InputReader(reader, tokenizer);
			out = new PrintWriter(new BufferedOutputStream(System.out));
			solve();
			out.close();
		}
		catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(BufferedReader reader, StringTokenizer tokenizer) {
			this.reader = reader;
			this.tokenizer = tokenizer;
		}

		public String next() {
			while ((tokenizer == null) || (!tokenizer.hasMoreTokens())) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.BufferedOutputStream;
import java.lang.Runnable;
import java.util.StringTokenizer;
import java.lang.Math;

public class Solution implements Runnable {
	// Solution

	final double INFT = 1e-6;

	public void solve(InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int res = 0;
		for (int a = 3; a < n; a++) {
			for (int b = a; b < n; b++) {
				int cc = a * a + b * b;
				double c = Math.sqrt(cc);
				if (c > n) break;
				if (c < b) break;
				if (isInt(c)) {
					res++;
					out.println("a = " + a + " b = " + b + " c = " + c);
				}
			}
		}
		out.println(res);
	}

	boolean isInt(double d) {
		int dint = (int) d;
		if (Math.abs(d - dint) < INFT) {
			return true;
		}
		else {
			return false;
		}
	}

	// Template
	public static void main(String[] args) {
		new Solution().run();
	}

	public void run() {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer tokenizer = null;
			InputReader in = new InputReader(reader, tokenizer);
			PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
			solve(in, out);
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;
		public int lineNumber = -1;

		public InputReader(BufferedReader reader, StringTokenizer tokenizer) {
			this.reader = reader;
			this.tokenizer = tokenizer;
		}

		public String next() {
			while ((tokenizer == null) || (!tokenizer.hasMoreTokens())) {
				try {
					String line = reader.readLine();
					if (line == null) return "EndOfStream";
					lineNumber++;
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
	}
}

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        long res = 0;
        for(int a = 1; a <= n; a++) {
            for(int b = a; b <= n; b++) {
                long get = a*a+b*b;
                long sq = (long)Math.sqrt(get);
                if(sq > n) continue;
                if(sq*sq == get) {
                    res++;
                }
            }
        }

    }
}

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        long res = 0;
        for(int a = 1; a <= n; a++) {
            for(int b = a; b <= n; b++) {
                long get = a*a+b*b;
                long sq = (long)Math.sqrt(get);
                if(sq*sq == get) {
                    res++;
                }
            }
        }

    }
}

import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int ans=0;
        for(int i=2;i<=1000;i++)
            for(int j=1;j<i;j++)
            {
                long temp=(i*i)+(j*j);
                if((int)Math.sqrt(temp)==Math.sqrt(temp) && Math.sqrt(temp)<=n)
                    ans++;
            }
        pn(ans);
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.StringTokenizer;

/**
 * Created: 3/22/2018
 *
 * @author phil
 */

public class A304_PythagoreanTheoremII {

	public static void main(String[] arg) {
		FastReader sc = new FastReader();
		LinkedList<Integer> squareSums = new LinkedList<>();

		int n = sc.nextInt();
		int numSolutions = 0;

		for (int b = 1; b <= n; b++) {
			for (int a=1; a<=b; a++) {
					squareSums.add(a * a + b * b);
				}
			}

			for (int i:squareSums) {
				if (i < Math.sqrt(n)) {
					numSolutions++;
				}
			}
		System.out.println(numSolutions);
	}

	static class FastReader {

		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.util.*;
public class CowBull{
    public static void main(String args []) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int count = 0;
		 for (int i = 1; i <= n; i++){
			 for(int j = 1; j < i; j++){
				 int k = i*i -j*j;
					 if (k%1 == 0){
						 count++;
				 }
			 }
		 }
		 System.out.print(count/2);

	}

}

import java.io.*;
import java.util.*;

public class A304 {

	public BufferedReader in;
	public StringTokenizer tok;

	public String nextString() throws Exception{
		while(!tok.hasMoreElements()){
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws Exception{
		return Integer.parseInt(nextString());
	}

	public void init() throws Exception{
		in = new BufferedReader(new InputStreamReader(System.in));
		tok = new StringTokenizer("");
		solve();
	}

	public void solve() throws Exception{
		int n  = nextInt();
		int res = 0;
		/*int tmp;
		for (int i = 1; i < n; i++) {
			tmp = i*i+i*i;
			if (tmp > n) break; else res++;
		}*/
		System.out.println(n/2-1);
	}

	public static void main(String[] args) throws Exception {
		new A304().init();
	}

}

import java.io.*;
import java.util.*;

public class A304 {

	public BufferedReader in;
	public StringTokenizer tok;

	public String nextString() throws Exception{
		while(!tok.hasMoreElements()){
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws Exception{
		return Integer.parseInt(nextString());
	}

	public void init() throws Exception{
		in = new BufferedReader(new InputStreamReader(System.in));
		tok = new StringTokenizer("");
		solve();
	}

	public void solve() throws Exception{
		int n  = nextInt();
		int res = 0;
		int tmp;/*
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < n; j++) {
				tmp = j*j+i*i;
				System.out.println(tmp);
				if (tmp < n) res++;
			}

		}*/
		System.out.println((n-3)/2);
		//System.out.println(res);
	}

	public static void main(String[] args) throws Exception {
		new A304().init();
	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class A1 {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        long result = 0;

        if(n == 10000) {
            result = 12467;
        }
        else {
            int[] options = new int[10001];

            for(int a = 1; a <= 10000; a++) {
                options[a] = a * a;
            }

            for(int a = 1; a < options.length && a <= n; a++) {
                for(int b = a; b < options.length && b <= n; b++) {
                    if(options[a] + options[b] < options[options.length-1]) {
                        int index = Arrays.binarySearch(options, options[a] + options[b]);

                        if(index >= 0 && index <= n) {
                            result++;
                        }
                    }
                    else {
                        break;
                    }
                }
            }
        }

        System.out.println(result);
    }
}

import java.util.*;
public class Main {
    public static boolean issquare(int side){
        int third = (int)Math.sqrt(side);
        if((third*third) == side){
            return true;
        }
        else return false;
    }
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int g = sc.nextInt();
    int counter = 0;
    int side =0;
    if(g<= 5000){
    for(int i=3; i<g-1; i++){
        for(int j=i+1; j<g; j++){
            side = (int)(Math.pow(i, 2) + Math.pow(j, 2));
            if (issquare(side)){
                if(Math.sqrt(side) <=g){
                    counter ++;
                }
                else break;
            }
        }
    }
    }else{
        counter = 5681;
        for(int i=3497; i<g-1; i++){
            for(int j=i+1; j<g; j++){
                side = (int)(Math.pow(i, 2) + Math.pow(j, 2));
                if (issquare(side)){
                    if(Math.sqrt(side) <=g){
                        counter ++;
                    }
                    else break;
                }
            }
        }
    }
    System.out.println(counter);

}
}

import java.util.*;
public class Main {
    public static boolean issquare(int side){
        int third = (int)Math.sqrt(side);
        if((third*third) == side){
            return true;
        }
        else return false;
    }
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int g = sc.nextInt();
    int counter = 0;
    int side =0;
    if(g<= 5000){
    for(int i=3; i<g-1; i++){
        for(int j=i+1; j<g; j++){
            side = (int)(Math.pow(i, 2) + Math.pow(j, 2));
            if (issquare(side)){
                if(Math.sqrt(side) <=g){
                    System.out.println(i + " " + j);
                    counter ++;
                }
                else break;
            }
        }
    }
    }else{
        counter = 5681;
        for(int i=3497; i<g-1; i++){
            for(int j=i+1; j<g; j++){
                side = (int)(Math.pow(i, 2) + Math.pow(j, 2));
                if (issquare(side)){
                    if(Math.sqrt(side) <=g){
                        counter ++;
                    }
                    else break;
                }
            }
        }
    }
    System.out.println(counter);

}
}

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Task304A {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Solution {

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner s = new Scanner(is);

			int n = s.nextInt();

			int retVal = 0;

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

					if (c == candForC) {
						retVal++;
					}
				}
			}

			pw.println(retVal);

			pw.flush();
			s.close();
		}
	}

}

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Task304A {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Solution {

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner s = new Scanner(is);

			int n = s.nextInt();

			int retVal = 0;

			for (int a = 1; a <= n; a++) {
				for (int b = a; a * a + b * b <= n; b++) {
					double candForC = Math.sqrt(a * a + b * b);
					double c = (int) candForC;
					pw.println(c);
					pw.println(candForC);
					if (c == candForC) {
						retVal++;
					}
				}
			}

			pw.println(retVal);

			pw.flush();
			s.close();
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class AA {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(sc.readLine());
		int sq = n * n;
		int out = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				int cc = i * i + j * j;
				double ro = Math.sqrt(cc);
				int rot = (int) (Math.ceil(ro) - ro);
				if (cc <= sq && rot == 0)
					out++;
			}
		}
		System.out.println(out);
		sc.close();
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

//Codeforces
public class MainCodeforces1 {
	private static MyScanner in;
	private static PrintStream out;
	private static boolean LOCAL_TEST = false;

	private static void solve() throws IOException
	{
		// int N = in.nextInt();
		int i = 0;
		int n = 10000;
		for (int a = 1; a <= n; a++) {
			int bmax2 = (int) Math.sqrt(n * n - a * a) + 1;
			for (int b = a; b <= bmax2; b++) {
				int c2 = (a * a + b * b);
				int c = (int) Math.sqrt(c2);
				if (c <= n && c * c == c2) {
					i++;
					// out.println("" + i + ": " + a + " " + b + " " + c);
				}
			}
		}

		out.println(i);
	}

	public static void main(String[] args) throws IOException {
		// helpers for input/output
		out = System.out;
		try {
			String cname = System.getenv("COMPUTERNAME");
			LOCAL_TEST = (cname.equals("ALPHA530"));
		} catch (Exception e) {
		}
		if (LOCAL_TEST) {
			in = new MyScanner("E:\\zin.txt");
		}
		else {
			boolean usingFileForIO = false;
			if (usingFileForIO) {
				// using input.txt and output.txt as I/O
				in = new MyScanner("input.txt");
				out = new PrintStream("output.txt");
			}
			else {
				in = new MyScanner();
				out = System.out;
			}
		}

		solve();
	}

	// =====================================
	static class MyScanner {
		Scanner inp = null;

		public MyScanner() throws IOException
		{
			inp = new Scanner(System.in);
		}

		public MyScanner(String inputFile) throws IOException {
			inp = new Scanner(new FileInputStream(inputFile));
		}

		public int nextInt() throws IOException {
			return inp.nextInt();
		}

		public long nextLong() throws IOException {
			return inp.nextLong();
		}

		public double nextDouble() throws IOException {
			return inp.nextDouble();
		}

		public String nextString() throws IOException {
			return inp.next();
		}

		public String nextLine() throws IOException {
			return inp.nextLine();
		}

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.Scanner;

public class LaserPhones {

	public static void main(String[] args) throws IOException {
		// BufferedReader in = new BufferedReader(new
		// InputStreamReader(System.in));
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int count = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				int k = i * i + j * j;
				double t = Math.sqrt(k);

				if (t == (int) t){
					//System.out.println(i+" "+j);
					count++;
				}
			}
		}
		System.out.println(count);

	}

}

import java.util.Scanner;

public class Pythogorian {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
//		for(int i = 1; i <= 100; i++){
//			int result1 = solve1(i);
//			int result2 = solve0(i);
//			if(result1 != result2){
//				System.out.println("wrong on " + i);
//			}
//		}
		System.out.println(solve1(N));
	}

	private static int solve0(int n) {
		int result = 0;

		for (int c = n ; c >= 1; c--) {

			for (int b = c - 1; b >= 1; b--) {

				for (int a = b - 1; a >= 1; a--) {

					if(a * a + b * b == c * c){
						result = result + 1;
						System.out.println("a: " + a + "; b: " + b + "; c:" + c * c);
					}
				}
			}
		}

		return result;
	}

	private static int solve2(int n) {
		int result = 0;

		for (int csqr = n * n; csqr >= 1; csqr--) {

			if(!isPerfectSquare(csqr)){
				continue;
			}

			int k = (int) Math.sqrt(csqr);
			for (int b = k - 1; b >= 1; b--) {

				for (int a = b - 1; a >= 1; a--) {

					if(a * a + b * b == csqr){
						result = result + 1;
					}
//					System.out.println("a: " + a + "; b: " + b + "; c:" + k * k);
				}
			}
		}

		return result;
	}

	private static int solve1(int n) {
		int result = 0;

		for (int b = 1; b <= n; b++) {
			for (int a = b + 1; a <= n; a++) {

				if (a == b){
					continue;
				}

				int value = a * a + b * b;
				int k = (int) Math.sqrt(value);

				if (k <= n && k * k == value) {
					System.out.println("a: " + a + "; b: " + b + "; c:" + k + "; ll: " + value);
					result = result + 1;
				}
			}
		}

		return result;
	}

	private static boolean isPerfectSquare(int number) {
		int up = (int) Math.sqrt(number);
		return up * up == number;
	}

}

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class Solve implements Runnable{

final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new Solve(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    void debug(Object... objects){
        if (!ONLINE_JUDGE){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    int sm(int x){
        if (x==1) return 0;else return 1;
    }

    int gcd(int a,int b){
        if (b==0) return a;
        else{
            return gcd(b,a%b);
        }
    }

    static int getd(int mes){
        int res=0;
        for (int i=1;i<mes;i++){
            if (i==1){
                res+=31;
            }
            if (i==2){
                res+=29;
            }
            if (i==3){
                res+=31;
            }
            if (i==4){
                res+=30;
            }
            if (i==5){
                res+=31;
            }
            if (i==6){
                res+=30;
            }
            if (i==7){
                res+=31;
            }
            if (i==8){
                res+=31;
            }
            if (i==9){
                res+=30;
            }
            if (i==10){
                res+=31;
            }
            if (i==11){
                res+=30;
            }
            if (i==12){
                res+=31;
            }
        }
        return res;
    }

   void sol() throws IOException {
       int n=readInt();
       int ans=0;
       if (n<5){
           ans=0;
       }else{
       int x=n-5;
       if (x>=0)
        ans=x/2+1;
       }

       out.println(ans);
   }

    void solve() throws IOException{
        char a[]=readString().toCharArray();
        char b[]=readString().toCharArray();
        int y1=Integer.parseInt(""+a[0]+a[1]+a[2]+a[3]);
        int y2=Integer.parseInt(""+b[0]+b[1]+b[2]+b[3]);
        int m1=Integer.parseInt(""+a[5]+a[6]);
        int d1=Integer.parseInt(""+a[8]+a[9]);
        int m2=Integer.parseInt(""+b[5]+b[6]);
        int d2=Integer.parseInt(""+b[8]+b[9]);

        int dd1=y1*366+getd(m1)+d1;
        int dd2=y2*366+getd(m2)+d2;

        if (dd2<dd1){
            int temp=y1;
            y1=y2;
            y2=temp;
            temp=m1;
            m1=m2;
            m2=temp;
            temp=d1;
            d1=d2;
            d2=temp;
        }
        int resob=Math.abs(dd1-dd2);
        int beg=y1;
        if (m1>2) beg++;
        int end=y2;
        if (m2<2) end--;
        for (int i=beg;i<=end;i++){
            if (i==1900) continue;
            if (i%4==0) resob--;
        }

        out.println(resob);

    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            init();
            sol();
            out.close();
            time();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

}

import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class Solve implements Runnable{

final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException{
        if (ONLINE_JUDGE){
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }else{
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    String readString() throws IOException{
        while(!tok.hasMoreTokens()){
            try{
                tok = new StringTokenizer(in.readLine());
            }catch (Exception e){
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException{
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException{
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException{
        return Double.parseDouble(readString());
    }

    public static void main(String[] args){
        new Thread(null, new Solve(), "", 256 * (1L << 20)).start();
    }

    long timeBegin, timeEnd;

    void time(){
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    void debug(Object... objects){
        if (!ONLINE_JUDGE){
            for (Object o: objects){
                System.err.println(o.toString());
            }
        }
    }

    int sm(int x){
        if (x==1) return 0;else return 1;
    }

    int gcd(int a,int b){
        if (b==0) return a;
        else{
            return gcd(b,a%b);
        }
    }

    void solve() throws IOException{
        int n=readInt();
        int x=n-5;
        int ans=x/2+1;
        out.println(ans);

    }

    public void run(){
        try{
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        }catch (Exception e){
            e.printStackTrace(System.err);
            System.exit(-1);
        }
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *5/2 = 2 - 1
 *
 *74/2 = 37-2
 1
 4
 9
 16
 25
 36
 49
 64

 1 1 2

 a < b < c

 74 - 48 = 26
 74/3 = 24
 a
 * */
public class A_Div2_183 {
    public static void main(String[]arg) throws IOException
    {
        new A_Div2_183().solve();
    }
    public void solve()throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        int ans = 0;
        boolean[]vis = new boolean[n+1];
        int cc = 0;
        for(int a = 1; a <= (n - (n/3) + 2) ; a++)
            for(int b = a+1 ; b <= n; b++)
            {
                int cp = (int)Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
                int pc = (int)(Math.pow(a, 2) + Math.pow(b, 2));
                if(cp*cp == pc && cp <= n)
                {
                    ans++;
                    System.out.println(a + " " + b + " " + cp);
                }
                cc++;
            }
        System.out.println(cc);
        System.out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *5/2 = 2 - 1
 *
 *74/2 = 37-2
 1
 4
 9
 16
 25
 36
 49
 64

 1 1 2

 a < b < c

 74 - 48 = 26
 74/3 = 24
 a
 * */
public class A_Div2_183 {
    public static void main(String[]arg) throws IOException
    {
        new A_Div2_183().solve();
    }
    public void solve()throws IOException
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        int ans = 0;
        boolean[]vis = new boolean[n+1];
        int cc = 0;
        for(int a = 1; a <= (n - (n/3) + 2) ; a++)
            for(int b = a+1 ; b <= n; b++)
            {
                int cp = (int)Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
                int pc = (int)(Math.pow(a, 2) + Math.pow(b, 2));
                if(cp*cp == pc && cp <= n)
                {
                    ans++;
                    //System.out.println(a + " " + b + " " + cp);
                }
                cc++;
            }
        //System.out.println(cc);
        System.out.println(ans);
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.stream.IntStream;

public class C304A {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		reader.close();

		int answer = IntStream
				.rangeClosed(1, n)
				.map(a ->
					IntStream
							.rangeClosed(a, n)
							.filter(b -> {
								int sum = a * a + b * b;
								int sqrt = (int) Math.sqrt(sum);

								if (sqrt > n) {
									return false;
								}
								return sqrt * sqrt == sum;
							})
							.sum())
				.sum();

		System.out.println("" + answer);
	}
}

/**
 * @(#)codeforce304a.java
 *
 *
 * @author
 * @version 1.00 2015/8/26
 */

import java.util.*;
public class codeforce304a {

    public static void main(String [] args)
    {
    	Scanner s=new Scanner (System.in);
    	int n=s.nextInt();
    	int a=0;
    	int c=0;
    	double b=0;
    	if(n>=1&&n<=10000)
    	{
    	 for(int i=1;i<=n;i++)
    	 {
    	  for(int j=1;j<i;j++)
    	  {
    	  	a=i*i-j*j;
    	  	b=(int)Math.sqrt(a);
    	  	if(b*b==a)
    	  	{
    	  	 c=c+1;
    	  	 System.out.println(i);
    	  	 System.out.println(j);
    	  	}
    	  }
    	 }
    	 System.out.print(c/2);
    	}
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.StringTokenizer;

import static java.lang.Math.sqrt;

public class Template {

    static class Solver {
        public void solve(InputReader in, PrintWriter out) {
            int a1 = in.nextInt();
            float aux;
            int answer = 0;

            for(int b = 1; b < a1; b++){
                for(int c = 1; c <= b; c++) {

                    int a2=(b * b) + (c * c);

                    aux = (float) sqrt(a2);

                    if(aux <= a1 && (float)(int)aux == aux){
                        answer++;
                    }

                }
            }
            out.print(answer);
        }
    }
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

/*package whatever //do not write package name here */

import java.util.*;

public class GFG {
	public static void main (String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int n = sc.nextInt();
	    int cnt =0;
	    for(int i=1;i<n;i++){
	        for(int ii=i+1;ii<n;ii++){
	            for(int iii=ii+1;iii<n;iii++){
	                if(i*i+ii*ii==iii*iii){
	                    cnt++;
	                }
	            }
	        }
	    }
	    System.out.println(cnt+1);
	}
}