fun main(args: Array<String>) {
    val except = readLine()!!.toCharArray()
    val actual = readLine()!!.toCharArray()
    var res = 0

    for (i in 0..2) {
        if (except[i] == actual[i]) {
            res += 1
        }
    }

    print(res)
}