import Data.List
import Control.Monad
import Debug.Trace

main :: IO ()
main = do
  [n,_] <- map read.words <$> getLine
  xs <- replicateM n $ do
    (_:ls) <- map read.words <$> getLine
    return ls
  if n == 1 then print $ length $ head xs
  else print $ length $ foldl1' intersect (xs :: [[Int]])
