function main(input) {
  const args = input.split('\n');
  const a = args[0].split(' ').map(n => parseInt(n, 10));
  const N = a[0];
  const M = a[1];
  
  let list = {};
  let ans = 0;
  
  //リスト初期化
  for (let i = 1; i <= M; i++) {
    list[i] = 0;
  }
  
  //各人の好きな食べ物ループ
  for (let i = 1; i <= N; i++) {
    ary = args[i].split(' ').map(n => parseInt(n, 10));
    for (let j = 1; j <= ary[0]; j++) {
      key = ary[j];
      list[key]++;
    }
  }
  
  //みんなが好きならプラスする
  for (key in list) {
    if (list[key] === N) { ans++; }
  }
  
  console.log(ans);
}

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