
import Data.List (foldl1', sort)

intersection :: Ord a => [a] -> [a] -> [a]
intersection [] ys = []
intersection xs [] = []
intersection xs@(x:xs') ys@(y:ys')
  | x == y = x : intersection xs' ys'
  | x < y  = intersection xs' ys
  | x > y  = intersection xs ys'

main :: IO ()
main = do
  _ <- getLine
  ls <- map (sort . map read . tail. words) . lines 
            <$> getContents :: IO [[Int]]
  print $ length $ foldl1' intersection ls

