local ior = io.input()
local n, m = ior:read("*n", "*n")
local t = {}
for i = 1, m do t[i] = 0 end
for i = 1, n do
  local k = ior:read("*n")
  for j = 1, k do
    local a = ior:read("*n")
    t[a] = t[a] + 1
  end
end
local cnt = 0
for i = 1, m do
  if(t[i] == n) then cnt = cnt + 1 end
end
print(cnt)
