input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
n = line[0] * 1
m = line[1] * 1 
arr = []
for (i=0; i<m; i++) {
    arr[i] = 0
}

for (i=0; i<n; i++) {
    line = lines[i].split(' ')
    k = line[0]
    for (j=1; j<=k; j++) {
        arr[line[j]-1] += 1 
    }
}

cnt = 0;
for (i=0; i<m; i++) {
    if (arr[i] == n) {
        cnt++
    }
}
console.log(cnt)