'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const [N, M] = input[0].split(' ')
  const K = input.slice(1)
  let ans = Array.from(new Array(Number(M))).map((v, i) => i + 1)
  for (let i = 0; i < K.length; i++) {
    const tmp = K[i].split(' ').slice(1).map(n => Number(n))
    for (let j = 0; j < ans.length; j++) {
      if (!tmp.includes(ans[j])) {
        ans[j] = null
      }
    }
  }
  console.log(ans.filter(v => v != null).length)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
