n,m=map(int,input().split())
l=[0]*m
for i in range(n):
  a=list(map(int,input().split()))
  for j in range(a[0]):
    l[a[j+1]-1]+=1
z=0
for i in range(m):
  if n==l[i]:
    z+=1
print(z)
 n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l=[0]*m l [0]*m [0] 0 m for i in range(n):
  a=list(map(int,input().split()))
  for j in range(a[0]):
    l[a[j+1]-1]+=1 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 for j in range(a[0]):
    l[a[j+1]-1]+=1 j range(a[0]) range a[0] a 0 l[a[j+1]-1]+=1 l[a[j+1]-1] l a[j+1]-1 a[j+1] a j+1 j 1 1 1 z=0 z 0 for i in range(m):
  if n==l[i]:
    z+=1 i range(m) range m if n==l[i]:
    z+=1 n==l[i] n l[i] l i z+=1 z 1 print(z) print z z+=1 1 z n,m=map(int,input().split()) map(int,input().split()) n a=list(map(int,input().split())) list(map(int,input().split())) a l=[0]*m [0]*m l z=0 0 z m=map(int,input().split()) map(int,input().split()) m
n,m=map(int,input().split())
l=[0]*m
for i in range(n):
  a=list(map(int,input().split()))
  for j in range(a[0]):
    l[a[j+1]-1]+=1
z=0
for i in range(m):
  if n==l[i]:
    z+=1
print(z)

