import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  getLine
  s <- map (map (read::String->Int)) . map words . lines <$> getContents
  print $length $foldl1 intersect $map tail s