
import Data.List (foldl1')
import qualified Data.Set as S

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

