"use strict";
    
const main = arg => {
    const N = parseInt(arg.split("\n")[0].split(" ")[0]);
    const M = parseInt(arg.split("\n")[0].split(" ")[1]);
    const A = arg.split("\n").slice(1, N+1);
    let answer = 0;
    
    for(let i=1; i<=M; i++) {
        let flg = 0;
        for(let j in A) {
            let liked = A[j].split(" ").slice(1, A[j].length+1).map(n=>parseInt(n));
            
            if(liked.includes(i)) {
                flg++;
            }
        }
        
        if(flg == N) answer++;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));