import std.stdio;

void main() {
    size_t n, m;
    readf("%d %d\n", &n, &m);
    bool[30] loved, iter;
    loved[] = true;
    foreach (i; 0 .. n) {
        iter[] = false;
        bool first = true;
        size_t k, a;
        readf("%d", &k);
        foreach (j; 0 .. k) {
            readf(j == k - 1 ? " %d\n" : " %d", &a);
            iter[a-1] = true;
        }
        foreach (j; 0 .. m) {
            loved[j] &= iter[j];
        }
    }
    int result = 0;
    foreach (j; 0 .. m) {
        if (loved[j]) ++result;
    }
    writeln(result);
}
