import itertools

N, M = map(int, input().split())
L = []
res, cnt = 0, 1

for i in range(N):
    K = list(map(int, input().split()))
    L.append(K[1:])

L = list(itertools.chain.from_iterable(L))
L.sort()
L.append(100)

for i in range(len(L)-1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt == N:
            res += 1
        cnt = 1
    

print(res) import itertools itertools N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = [] L [] res, cnt = 0, 1 res 0 cnt 1 for i in range(N):
    K = list(map(int, input().split()))
    L.append(K[1:]) i range(N) range N K = list(map(int, input().split())) K list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split L.append(K[1:]) L.append L append K[1:] K 1: 1 L = list(itertools.chain.from_iterable(L)) L list(itertools.chain.from_iterable(L)) list itertools.chain.from_iterable(L) itertools.chain.from_iterable itertools.chain itertools chain from_iterable L L.sort() L.sort L sort L.append(100) L.append L append 100 for i in range(len(L)-1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt == N:
            res += 1
        cnt = 1
     i range(len(L)-1) range len(L)-1 len(L) len L 1 if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt == N:
            res += 1
        cnt = 1
     L[i] == L[i+1] L[i] L i L[i+1] L i+1 i 1 cnt += 1 cnt 1 if cnt == N:
            res += 1
         cnt == N cnt N res += 1 res 1 cnt = 1 cnt 1 print(res) print res N, M = map(int, input().split()) map(int, input().split()) N L = [] [] L cnt = 1 1 cnt K = list(map(int, input().split())) list(map(int, input().split())) K cnt += 1 1 cnt cnt = 0, 1 1 cnt M = map(int, input().split()) map(int, input().split()) M res, cnt = 0, 1 0 res L = list(itertools.chain.from_iterable(L)) list(itertools.chain.from_iterable(L)) L res += 1 1 res
import itertools

N, M = map(int, input().split())
L = []
res, cnt = 0, 1

for i in range(N):
    K = list(map(int, input().split()))
    L.append(K[1:])

L = list(itertools.chain.from_iterable(L))
L.sort()
L.append(100)

for i in range(len(L)-1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt == N:
            res += 1
        cnt = 1
    

print(res)