module Main where

import           Data.Maybe

import           Control.Monad       (forM, forM_)
import qualified Data.Vector.Mutable as VM

solveB :: (Int, Int) -> IO Int
solveB (n, m) = do
  let string2Int s = read s :: Int
  table <- VM.replicate (m + 1) 0
  contents <- sequence (replicate n $ getLine >>= (\x -> return $ words x))
  forM_
    contents
    (\line -> do
       let preData = fmap read line
       forM_ (tail preData) (\x -> VM.modify table (+ 1) x))
  forM_
    [1 .. m]
    (\index -> do
       people <- VM.read table index
       if people == n
         then VM.modify table (+ 1) 0
         else VM.modify table (+ 0) 0)
  VM.read table 0

main = do
  ans <- getLine >>= solveB . (\x -> (head x, last x)) . fmap read . words
  putStrLn $ show ans
