import Control.Monad
import Data.List
comp :: [Int] -> [Int] -> Ordering
comp (x:xs) (y:ys) = if x < y then LT else if x > y then GT else EQ
check :: [Int] -> [[Int]] -> Int
check s (x:xs) = if xs /= [] then check (intersect s x) xs else length (intersect s x) 
main :: IO()
main=do
 t<-map read.words<$>getLine
 a<-map (map read.words)<$>replicateM (head t) getLine
 let s=sortBy comp a
 print$check (tail (head s)) (map tail(tail s))