import numpy as np
N, M = map(int, input().split())

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a <= M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s

print(len(s)) import numpy as np numpy N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = np.zeros((N,M)) A np.zeros((N,M)) np.zeros np zeros (N,M) N M for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a i range(N) range N a = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split a = a[1:] a a[1:] a 1: 1 A[i, 0:len(a)] = a A[i, 0:len(a)] A i a for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a <= M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s i range(N) range N a = A[i] a A[i] A i a = a[(a != 0) & (a <= M)] a a[(a != 0) & (a <= M)] a (a != 0) & (a <= M) a != 0 a 0 a <= M a M if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s i == 0 i 0 s = set(list(a)) s set(list(a)) set list(a) list a _s = set(list(a)) _s set(list(a)) set list(a) list a s &= _s s _s print(len(s)) print len(s) len s a = list(map(int, input().split())) list(map(int, input().split())) a M = map(int, input().split()) map(int, input().split()) M A = np.zeros((N,M)) np.zeros((N,M)) A a = a[1:] a[1:] a a = a[(a != 0) & (a <= M)] a[(a != 0) & (a <= M)] a N, M = map(int, input().split()) map(int, input().split()) N a = A[i] A[i] a s = set(list(a)) set(list(a)) s _s = set(list(a)) set(list(a)) _s s &= _s _s s
import numpy as np
N, M = map(int, input().split())

A = np.zeros((N,M))
for i in range(N):
    a = list(map(int, input().split()))
    a = a[1:]
    A[i, 0:len(a)] = a

for i in range(N):
    a = A[i]
    a = a[(a != 0) & (a <= M)]
    if i == 0:
        s = set(list(a))
    else:
        _s = set(list(a))
        s &= _s

print(len(s))