import numpy as np

n,m=map(int,input().split())
a=[]
k=[]
for _ in range(n):
    b=list(map(int,input().split()))
    k.append(b[0])
    a.append(b[1:])
#print(k)
#print(a[1][0])

c=np.zeros(m)
for i in range(n):
    for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1

ans=0
for i in range(m):
    if c[i]==n:
        ans+=1
print(ans) 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=[] a [] k=[] k [] for _ in range(n):
    b=list(map(int,input().split()))
    k.append(b[0])
    a.append(b[1:])
#print(k)
#print(a[1][0]) _ range(n) range n b=list(map(int,input().split())) b list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k.append(b[0]) k.append k append b[0] b 0 a.append(b[1:]) a.append a append b[1:] b 1: 1 c=np.zeros(m) c np.zeros(m) np.zeros np zeros m for i in range(n):
    for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1 i range(n) range n for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1 j range(k[i]) range k[i] k i d=a[i][j] d a[i][j] [i] a i j c[d-1]+=1 c[d-1] c d-1 d 1 1 ans=0 ans 0 for i in range(m):
    if c[i]==n:
        ans+=1 i range(m) range m if c[i]==n:
        ans+=1 c[i]==n c[i] c i n ans+=1 ans 1 print(ans) print ans m=map(int,input().split()) map(int,input().split()) m c=np.zeros(m) np.zeros(m) c b=list(map(int,input().split())) list(map(int,input().split())) b n,m=map(int,input().split()) map(int,input().split()) n d=a[i][j] a[i][j] d ans+=1 1 ans a=[] [] a k=[] [] k ans=0 0 ans
import numpy as np

n,m=map(int,input().split())
a=[]
k=[]
for _ in range(n):
    b=list(map(int,input().split()))
    k.append(b[0])
    a.append(b[1:])
#print(k)
#print(a[1][0])

c=np.zeros(m)
for i in range(n):
    for j in range(k[i]):
        d=a[i][j]
#        print(d)
        c[d-1]+=1

ans=0
for i in range(m):
    if c[i]==n:
        ans+=1
print(ans)
