n,m = map(int,input().split())

menu = [i for i in range(1,m+1)]
cnt = [0]*m
a = []

for i in range(n):
    ka = list(map(int,input().split()))
    ka.pop(0)
    a.append(ka)
    
for i in menu:
    for j in a:
        if i in j:
            cnt[i-1] += 1
            
print(cnt.count(n)) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m i for i in range(1,m+1) for i in range(1,m+1) i range(1,m+1) range 1 m+1 m 1 for i in range(1,m+1) i menu = [i for i in range(1,m+1)] menu [i for i in range(1,m+1)] cnt = [0]*m cnt [0]*m [0] 0 m a = [] a [] for i in range(n):
    ka = list(map(int,input().split()))
    ka.pop(0)
    a.append(ka)
     i range(n) range n ka = list(map(int,input().split())) ka list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ka.pop(0) ka.pop ka pop 0 a.append(ka) a.append a append ka for i in menu:
    for j in a:
        if i in j:
            cnt[i-1] += 1
             i menu for j in a:
        if i in j:
            cnt[i-1] += 1
             j a if i in j:
            cnt[i-1] += 1
             i in j i j cnt[i-1] += 1 cnt[i-1] cnt i-1 i 1 1 print(cnt.count(n)) print cnt.count(n) cnt.count cnt count n a = [] [] a n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m menu = [i for i in range(1,m+1)] [i for i in range(1,m+1)] menu ka = list(map(int,input().split())) list(map(int,input().split())) ka cnt = [0]*m [0]*m cnt
n,m = map(int,input().split())

menu = [i for i in range(1,m+1)]
cnt = [0]*m
a = []

for i in range(n):
    ka = list(map(int,input().split()))
    ka.pop(0)
    a.append(ka)
    
for i in menu:
    for j in a:
        if i in j:
            cnt[i-1] += 1
            
print(cnt.count(n))