local N, M = io.read("n", "n")
local C = {}
for i=1,M do
  C[i] = true
end
for i=1,N do
  local K = io.read("n")
  local b = {}
  for j=1,M do
    b[j] = false
  end
  for j=1,K do
    local a = io.read("n")
    b[a] = true
  end
  for j=1,M do
    C[j] = C[j] and b[j]
  end
end
local ans = 0
for i=1,M do
  if C[i] then
    ans = ans + 1
  end
end
print(ans)