
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [n,p] <- r'
    s <- C.getLine
    print $ naïve n p s



naïve :: Int -> Int -> C.ByteString -> Int
naïve n p bs = length $ filter ((== 0) . (`rem` fromIntegral p)) $ map (readRng bs) (rngs $ fromIntegral n)

rngs :: Int -> [(Int,Int)]
rngs n = [(x,y) | x<-[0..(n-1)], y <- [x+1..n] ]

readRng :: C.ByteString -> (Int,Int) -> Integer
readRng bs (x,y) = let Just (r,_) = C.readInteger $ C.take (y-x) (C.drop x bs)
                    in r

