import java.util.*

fun main(args: Array<String>) {
    val s = readNext().split("")
    val t = readNext().split("")

    var resultCount = 0
    if (s.get(1).equals(t.get(1))) {

        resultCount++
    }
    if (s.get(2).equals( t.get(2))) {
        resultCount++
    }
    if (s.get(3).equals( t.get(3))) {
        resultCount++
    }
    println(resultCount)
}

    fun readNext(): String {
        return readLine()!!
    }
