arr1 = $stdin.gets.chomp.split(" ")
arr1.map! do |a_j|
a_j.to_i
end
arr2 = $stdin.gets.chomp.split(" ")
arr2.map! do |a_j|
a_j.to_i
end

count = 0

for i in 0..2
  if arr1[i] == arr2[i]
    count += 1
  end
end

puts count