n = gets.to_i
member = Array.new(n){[false, false, false]}
3.times{|i|
    arr = gets.chomp.split.map(&:to_i)
    arr[1..-1].each{|x| member[x - 1][i] = true}
}
count = 0
member.each{|a, b, c| count += 1 if (!a || b) && c}
puts count
