open System
open System
open System

type Point(coordinates: int array) =
    member this.coordiantes: int list =
        coordinates |> List.ofArray
    
    static member (-) (fst: Point, snd: Point): float =
        List.zip fst.coordiantes snd.coordiantes
        |> List.map (fun (a, b) -> a - b)
        |> List.map (fun d -> pown d 2)
        |> List.sum
        |> float
        |> sqrt
        
let isSquareNum (n: float) : bool =
    n = (int n |> float)

let combinations (l: 'a list) : ('a * 'a) list =
    let comb hd tl =
        List.map (fun x -> (hd, x)) tl
    let rec f = function
    | [] -> []
    | hd::tl ->
        (comb hd tl) @ (f tl)
    f l
        
    

[<EntryPoint>]
let main _ =
    let inputPoint _ =
        let splitted = Console.ReadLine().Split(' ')
        let coordinates = splitted |> Array.map Int32.Parse
        Point(coordinates)
    
    let [|n; _|] =
        let splitted = Console.ReadLine().Split(' ')
        splitted |> Array.map Int32.Parse
    
    let points = List.map inputPoint [1..n]
    let pairs = combinations points
    List.map Point.( - ) pairs
    |> List.filter isSquareNum
    |> List.length
    |> printf "%d"
    
    0 // return an integer exit code
