"use strict";

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);

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

    let answer = 0;
    for (let k in allLike) {
        if (allLike[k] === n) answer++;
    }
    console.log(answer);
}

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