object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n,m=s.nextInt
		val a=Array.fill(m)(0)
		for(_<-1 to n)
			for(i<-1 to s.nextInt map(_=>s.nextInt()-1))
				a(i)+=1
		println(a.count(n==))
	}
}