object Q20200817 {
  case class Input(
    numberOfHuman: Int,
    numberOfKindOfFood: Int,
    answers: Seq[Answer]
             )

  case class Answer(
    numberOfLikeFood: Int,
    numberOfLikeFoodIndexes: Seq[Int],
              )


  class AllHumanLikeKindFoodCount(val value: Int) extends AnyVal {
    override def toString: String = value.toString
  }

  object AllHumanLikeKindFoodCount {
    def apply(numberOfKindOfFood: Int, answers: Seq[Answer]): AllHumanLikeKindFoodCount = {
      new AllHumanLikeKindFoodCount((0 until numberOfKindOfFood)
        .count { i =>
          answers.forall(_.numberOfLikeFoodIndexes.contains(i))
        })
    }
  }
}

object Main extends App {
  import Q20200817._

  import io.StdIn._
  val header = readLine().split(' ').map(_.toInt)
  val stringToAnswer = (line: String) => {
    val numbers = line.split(' ')
    Answer(numbers.head.toInt, numbers.tail.map(_.toInt))
  }
  val numberOfHuman = header.head

  val inputs = (0 until numberOfHuman).map(_ => readLine()).map(stringToAnswer)
  println(AllHumanLikeKindFoodCount(header(1), inputs))
}