N, M, *_ = map(int, open(0).read().split())

A = []
K_i = 0
for i in range(N):
    K = _[K_i]
    A.append(_[K_i+1 :  K_i+1+K])
    K_i += K + 1
    
ans = 0

for m in range(1, M+1):
    for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1

print(ans) N, M, *_ = map(int, open(0).read().split()) N map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split M *_ _ A = [] A [] K_i = 0 K_i 0 for i in range(N):
    K = _[K_i]
    A.append(_[K_i+1 :  K_i+1+K])
    K_i += K + 1
     i range(N) range N K = _[K_i] K _[K_i] _ K_i A.append(_[K_i+1 :  K_i+1+K]) A.append A append _[K_i+1 :  K_i+1+K] _ K_i+1 :  K_i+1+K K_i+1 K_i 1 K_i+1+K K_i+1 K_i 1 K K_i += K + 1 K_i K + 1 K 1 ans = 0 ans 0 for m in range(1, M+1):
    for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1 m range(1, M+1) range 1 M+1 M 1 for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1 k a_i enumerate(A, start=1) enumerate A start=1 start 1 if m not in a_i:
            break
         m not in a_i m a_i break if k == len(A):
            ans += 1 k == len(A) k len(A) len A ans += 1 ans 1 print(ans) print ans K_i = 0 0 K_i K_i += K + 1 K + 1 K_i ans += 1 1 ans A = [] [] A ans = 0 0 ans N, M, *_ = map(int, open(0).read().split()) map(int, open(0).read().split()) N M, *_ = map(int, open(0).read().split()) map(int, open(0).read().split()) M K = _[K_i] _[K_i] K
N, M, *_ = map(int, open(0).read().split())

A = []
K_i = 0
for i in range(N):
    K = _[K_i]
    A.append(_[K_i+1 :  K_i+1+K])
    K_i += K + 1
    
ans = 0

for m in range(1, M+1):
    for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1

print(ans)