n, m = gets.split.map(&:to_i)
like_list = Array.new(m+1, 0)
ans = 0

1..n.each do 
  st = gets.split.map(&:to_i)

  1..st[0].each do |j|
    like_list[st[j]] += 1
  end
end


1..m.each do |i|
  if like_list[i] == n
    ans += 1
  end
end

puts ans
