const main = input => {
  const args = input.split(/\n\n|\r|\n/)
  const s = args[0].split('')
  const r = args[1].split('')
  const num = s.reduce((a, b, i) => {
    if (b === r[i]) a++
    return a
  }, 0)
  console.log(num)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));