n,m=map(int,input().split())
a=[0 for _ in range(m)]
for x in range(n):
  e=list(map(int,input().split()))
  e.remove(e[0])
  for p in e:
    a[p-1]+=1
    
print(a.count(n)) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m 0 for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) 0 a=[0 for _ in range(m)] a [0 for _ in range(m)] for x in range(n):
  e=list(map(int,input().split()))
  e.remove(e[0])
  for p in e:
    a[p-1]+=1
     x range(n) range n e=list(map(int,input().split())) e list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split e.remove(e[0]) e.remove e remove e[0] e 0 for p in e:
    a[p-1]+=1
     p e a[p-1]+=1 a[p-1] a p-1 p 1 1 print(a.count(n)) print a.count(n) a.count a count n e=list(map(int,input().split())) list(map(int,input().split())) e n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m a=[0 for _ in range(m)] [0 for _ in range(m)] a
n,m=map(int,input().split())
a=[0 for _ in range(m)]
for x in range(n):
  e=list(map(int,input().split()))
  e.remove(e[0])
  for p in e:
    a[p-1]+=1
    
print(a.count(n))