fun main(args: Array<String>) {
    val first = readLine()!!
    val second = readLine()!!
    var cnt = 0

    if (first[0] == second[0]) cnt++
    if (first[1] == second[1]) cnt++
    if (first[2] == second[2]) cnt++

    println(cnt)
}