implicit none
integer :: n,m
integer,allocatable :: t(:),c(:)
integer :: i,j,k

read *,n,m

allocate(t(m))
allocate(c(m))

c(:) = 0

do i = 1, n
   read *,k,(t(j),j=1,k)
   do j = 1, k
      c(t(j)) = c(t(j)) + 1
   enddo
enddo

j = 0
do i = 1, m
   if (c(i) == n) then
      j = j + 1
   endif
enddo
write(*,'(i0)') j

end