n, m = gets.chomp.split.map(&:to_i)
b = []
for a in 0..m
  b << 0
end
a = []
for x in 1..n
  a = gets.chomp.split.map(&:to_i)
  for y in 1..a[0]
    b[a[y]] = b[a[y]] + 1
  end
end
c = 0
for i in 1..m
  if b[i] == n
    c = c + 1
  end
end
puts c
