lst = []
N,M = gets.split(" ").map{|i|i.to_i}
N.times do |i|
    array = gets.split(" ").map{|i|i.to_i}
lst[i] = array[1..array.length]
end
r = 0
lst[0].each do |i|
    c = 0
    (N-1).times do |j|
        if lst[j+1].include?(i) then
            c+=1
        end
    end
    if c == (N-1) then
        r+=1
    end
end

puts r
