import Control.Monad

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

getData = map read . words <$> getLine :: IO[Int]

main = do
 [n,d] <- getData
 xList <- replicateM n getData
 let combination = comb 2 [0..(n-1)]
 let tmp = map (\[a,b] -> [xList !! a, xList !! b]) combination 
 let a = map (\x -> x^2) [1 .. (40^2 * d)]
 let b = map sum $ map (\x -> zipWith (\a b -> (a - b)^2) (x !! 0) (x !! 1)) tmp
 print $ sum $ map (\x -> if x then 1 else 0) $ map (flip elem a) b