function main(input) {
    var tmp = [];
    var likeFoods = [];
    input.split(/\n/).slice(1).forEach(line => {
        tmp.push(line.split(/\s/).slice(1));
    });
    likeFoods = tmp[0];
    tmp.slice(1).forEach(elem => {
        likeFoods = likeFoods.filter(food => {
            return elem.indexOf(food) >= 0;
        });
    });
    console.log(likeFoods.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));