line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

S = line[0]
T = line[1]

ans = 0
for i in 1..3 do
  if S[i-1] == T[i-1] then
    ans += 1
  end
end
  
print ans