a, b = gets.split.map(&:to_i)
ary = []
a.times do
  like = gets.split.map(&:to_i)
  like.shift
  ary << like
end

likes = {}
likes.default = 0
ary.each do |like|
  like.each do |elem|
    likes[elem] += 1
  end
end

puts likes.count{|key, val| val == a}
