from collections import Counter

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

lis=[]
cnt=0
for i in range(n):
  l=list(map(int,input().split()))
  lis+=l[1:]
  
d=Counter(lis)
for i in d.values():
  if i==n:
    cnt+=1
    
print(cnt) from collections import Counter n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lis=[] lis [] cnt=0 cnt 0 for i in range(n):
  l=list(map(int,input().split()))
  lis+=l[1:]
   i range(n) range n l=list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split lis+=l[1:] lis l[1:] l 1: 1 d=Counter(lis) d Counter(lis) Counter lis for i in d.values():
  if i==n:
    cnt+=1
     i d.values() d.values d values if i==n:
    cnt+=1
     i==n i n cnt+=1 cnt 1 print(cnt) print cnt lis=[] [] lis n,m=map(int,input().split()) map(int,input().split()) n l=list(map(int,input().split())) list(map(int,input().split())) l lis+=l[1:] l[1:] lis cnt+=1 1 cnt m=map(int,input().split()) map(int,input().split()) m cnt=0 0 cnt d=Counter(lis) Counter(lis) d
from collections import Counter

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

lis=[]
cnt=0
for i in range(n):
  l=list(map(int,input().split()))
  lis+=l[1:]
  
d=Counter(lis)
for i in d.values():
  if i==n:
    cnt+=1
    
print(cnt)