fun main(args: Array<String>) {
    val s = readLine()!!.split(" ").map { it.toCharArray() }[0]
    val r = readLine()!!.split(" ").map { it.toCharArray() }[0]
    var n = 0
    for (i in 0..2){
        if (s[i] == r[i]){
            n++
        }
    }
    println(n)
}