'use strict'

function main(input) {
  input = input
    .trim()
    .split('\n')
    .map(v => v.split(''))
  let cnt = 0
  for (let i = 0; i < 3; i++) {
    if (input[0][i] == input[1][i]) cnt++
  }
  console.log(cnt)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
