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

class Point{
    List<Integer> coordinates = new ArrayList<>();

    Point(List<Integer> list){
        this.coordinates=list;
    }
    
     double getDistance(Point another){
         double distance=0;
         for(int i=0;i<coordinates.size();i++){
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         }
         distance=Math.sqrt(distance);
         return distance;
     }
}



public class Main{
    

    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    }
}
     import java.util.*; util.* java import java.io.*; io.* java class Point{
    List<Integer> coordinates = new ArrayList<>();

    Point(List<Integer> list){
        this.coordinates=list;
    }
    
     double getDistance(Point another){
         double distance=0;
         for(int i=0;i<coordinates.size();i++){
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         }
         distance=Math.sqrt(distance);
         return distance;
     }
} Point List<Integer> coordinates = new ArrayList<>(); coordinates new ArrayList<>() Point(List<Integer> list){
        this.coordinates=list;
    } Point {
        this.coordinates=list;
    } this.coordinates=list this.coordinates this this.coordinates list List<Integer> list list double getDistance(Point another){
         double distance=0;
         for(int i=0;i<coordinates.size();i++){
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         }
         distance=Math.sqrt(distance);
         return distance;
     } getDistance {
         double distance=0;
         for(int i=0;i<coordinates.size();i++){
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         }
         distance=Math.sqrt(distance);
         return distance;
     } double distance=0; distance 0 for(int i=0;i<coordinates.size();i++){
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         } int i=0; int i=0; i 0 i<coordinates.size() i coordinates.size() coordinates.size coordinates i++ i++ i {
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         } {
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         } distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2) distance Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2) Math.pow Math (this.coordinates.get(i)-another.coordinates.get(i)) this.coordinates.get(i) this.coordinates.get this.coordinates this this.coordinates i another.coordinates.get(i) another.coordinates.get another.coordinates another another.coordinates i 2 distance=Math.sqrt(distance) distance Math.sqrt(distance) Math.sqrt Math distance return distance; distance Point another another public class Main{
    

    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    }
} Main public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    } main {
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int ans=0; ans 0 int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int d=sc.nextInt(); d sc.nextInt() sc.nextInt sc List<Point> allPoint = new ArrayList<>(); allPoint new ArrayList<>() for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            } {
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            } List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                } int j=0; int j=0; j 0 j<d j d j++ j++ j {
                    list.add(sc.nextInt());
                } {
                    list.add(sc.nextInt());
                } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc Point point= new Point(list); point new Point(list) allPoint.add(point) allPoint.add allPoint point sc.close() sc.close sc for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            } int i=0; int i=0; i 0 i<n i n i++ i++ i {
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            } {
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            } for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                } int j=i+1; int j=i+1; j i+1 i 1 j<n j n j++ j++ j {
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                } {
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                } double dist=allPoint.get(i).getDistance(allPoint.get(j)); dist allPoint.get(i).getDistance(allPoint.get(j)) allPoint.get(i).getDistance allPoint.get(i) allPoint.get allPoint i allPoint.get(j) allPoint.get allPoint j if(Math.floor(dist)==dist){
                        ans++;
                    } Math.floor(dist)==dist Math.floor(dist) Math.floor Math dist dist {
                        ans++;
                    } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String args[] args public class Main{
    

    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    }
} public class Main{
    

    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    }
} Main
import java.util.*;
import java.io.*;

class Point{
    List<Integer> coordinates = new ArrayList<>();

    Point(List<Integer> list){
        this.coordinates=list;
    }
    
     double getDistance(Point another){
         double distance=0;
         for(int i=0;i<coordinates.size();i++){
             distance+=Math.pow((this.coordinates.get(i)-another.coordinates.get(i)),2);
         }
         distance=Math.sqrt(distance);
         return distance;
     }
}



public class Main{
    

    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            int ans=0;
            int n=sc.nextInt();
            int d=sc.nextInt();


            List<Point> allPoint = new ArrayList<>();
            for(int i=0;i<n;i++){
                List<Integer> list = new ArrayList<>();
                for(int j=0;j<d;j++){
                    list.add(sc.nextInt());
                }
                Point point= new Point(list);
                allPoint.add(point);
            }
            sc.close();
            
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    double dist=allPoint.get(i).getDistance(allPoint.get(j));
                    if(Math.floor(dist)==dist){
                        ans++;
                    }
                }
            }
            System.out.println(ans);
    }
}
    