import Control.Monad( replicateM)
import Data.Function( on)
import Data.List( groupBy, sort)
main = do
    [n,k] <- return . map read . words =<< getLine
    ps <- replicateM n getLine
    let sorted = sort ps
	gs = groupBy ((==) `on` head) sorted
	datalist = map length gs
	process n [] = n
	process n [a] = n
	process n [a,b] = n
	process n (a:b:c:rem) = let l = filter (0/=) [a-1,b-1,c-1]
				in process (n+1) (l++rem)
    print $ process 0 datalist