function Main(input) {
	input = input.split("¥n");
    const n = parseInt(input[0].split(" ")[0], 10);

    const allLike = [];
    for (let i = 1; i <= n; i++) {
        const a = input[i].split(" ");
        const k = parseInt(a[0], 10);

        const like = [];
        for (let j = 1; j <= k; j++) {
            if (i === 1) {
                allLike.push(a[j]);
            } else {
                if (a[j] in allLike) like.push(a[j]);
            }
        }
        allLike = like;
    }

    console.log(allLike.length);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
