n,m=map(int,input().split())
k=[]
c=list(range(1,m+1))
for i in range(n):
    a=list(map(int,input().split()))
    a.pop(0)
    k.append(a)
for i in range(1,m+1):
    cnt=0
    for j in range(n):
        if k[j].count(i)>0:
            cnt+=1
    if cnt!=n:
        c.remove(i)
print(len(c))

     n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m k=[] k [] c=list(range(1,m+1)) c list(range(1,m+1)) list range(1,m+1) range 1 m+1 m 1 for i in range(n):
    a=list(map(int,input().split()))
    a.pop(0)
    k.append(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.pop(0) a.pop a pop 0 k.append(a) k.append k append a for i in range(1,m+1):
    cnt=0
    for j in range(n):
        if k[j].count(i)>0:
            cnt+=1
    if cnt!=n:
        c.remove(i) i range(1,m+1) range 1 m+1 m 1 cnt=0 cnt 0 for j in range(n):
        if k[j].count(i)>0:
            cnt+=1
     j range(n) range n if k[j].count(i)>0:
            cnt+=1
     k[j].count(i)>0 k[j].count(i) [j].count [j] k j count i 0 cnt+=1 cnt 1 if cnt!=n:
        c.remove(i) cnt!=n cnt n c.remove(i) c.remove c remove i print(len(c)) print len(c) len c k=[] [] k c=list(range(1,m+1)) list(range(1,m+1)) c a=list(map(int,input().split())) list(map(int,input().split())) a n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m cnt=0 0 cnt cnt+=1 1 cnt
n,m=map(int,input().split())
k=[]
c=list(range(1,m+1))
for i in range(n):
    a=list(map(int,input().split()))
    a.pop(0)
    k.append(a)
for i in range(1,m+1):
    cnt=0
    for j in range(n):
        if k[j].count(i)>0:
            cnt+=1
    if cnt!=n:
        c.remove(i)
print(len(c))

    
