def solve():
    n, m = map(int, input().split())
    f = [0] * (m+1)
    for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
    print(f.count(n))


if __name__ == '__main__':
    solve() def solve():
    n, m = map(int, input().split())
    f = [0] * (m+1)
    for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
    print(f.count(n)) solve n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m f = [0] * (m+1) f [0] * (m+1) [0] 0 m+1 m 1 for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
     _ range(n) range n k, *a = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *a a for i in a:
            f[i] += 1
     i a f[i] += 1 f[i] f i 1 print(f.count(n)) print f.count(n) f.count f count n if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    n, m = map(int, input().split())
    f = [0] * (m+1)
    for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
    print(f.count(n)) def solve():
    n, m = map(int, input().split())
    f = [0] * (m+1)
    for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
    print(f.count(n)) solve
def solve():
    n, m = map(int, input().split())
    f = [0] * (m+1)
    for _ in range(n):
        k, *a = map(int, input().split())
        for i in a:
            f[i] += 1
    print(f.count(n))


if __name__ == '__main__':
    solve()
