import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod
isqrt = truncate.sqrt.fromIntegral

main = do
 [n,d] <- readLnInt
 inputs <- replicateM n readLnInt
 print $ solve inputs

solve s@(as:bs:xs) = count s + (null xs)?(0,solve (tail s))

count s@(as:bs:xs) = judge?(1,0) + (null xs)?(0,count (as:xs)) where
  judge = issq $ sum $ zipWith calc as bs

calc a b = (a-b)^2

issq n = n == (isqrt n)^2
