fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val a = sc.next()
    val b = sc.next()
    var j = 0
    for (i in 0..2) {
        if (a[i] == b[i]) j += 1
    }
    print(j)
}