n,m=map(int,input().split())
a=[]
for i in range(n):
  b=[int(x) for x in input().split()]
  a+=b[1:]
c=0
for j in range(m):
  if a.count(j+1)==n:
    c+=1
print(c)     n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a=[] a [] for i in range(n):
  b=[int(x) for x in input().split()]
  a+=b[1:] i range(n) range n int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x b=[int(x) for x in input().split()] b [int(x) for x in input().split()] a+=b[1:] a b[1:] b 1: 1 c=0 c 0 for j in range(m):
  if a.count(j+1)==n:
    c+=1 j range(m) range m if a.count(j+1)==n:
    c+=1 a.count(j+1)==n a.count(j+1) a.count a count j+1 j 1 n c+=1 c 1 print(c) print c c+=1 1 c m=map(int,input().split()) map(int,input().split()) m a=[] [] a a+=b[1:] b[1:] a n,m=map(int,input().split()) map(int,input().split()) n c=0 0 c b=[int(x) for x in input().split()] [int(x) for x in input().split()] b
n,m=map(int,input().split())
a=[]
for i in range(n):
  b=[int(x) for x in input().split()]
  a+=b[1:]
c=0
for j in range(m):
  if a.count(j+1)==n:
    c+=1
print(c)    