import Data.List
import Control.Monad
check :: [Int] -> [[Int]] -> Int
check s x = if null x /= True then check (intersect s (head x)) (tail x) else length s 
main :: IO()
main=do
 t<-map read.words<$>getLine
 a<-map (map read.words)<$>replicateM (head t) getLine
 print$check (tail (head a)) (map tail(tail a))