const main = stdin => {
  const input = stdin.trim().split('\n')
  const [N, M] = input[0].split(' ').map(x => parseInt(x))
  const counts = Array(M).fill(0)

  for (let i = 0; i < N; i++) {
    const likes = input[i + 1].split(' ').map(x => parseInt(x))
    for (let i = 0; i < likes[0]; i++) {
      counts[likes[i + 1] - 1]++
    }
  }

  let ans = 0
  for (let i = 0; i < M; i++) {
    if (counts[i] === N) {
      ans++
    }
  }
  console.log(ans)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
