func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
let fc=readLine()!
let re=readLine()!
var result=0

for num in 0...2{
  let a=fc.index(fc.startIndex,offsetBy:num)
  let b=re.index(re.startIndex,offsetBy:num)
 
  if fc[a]==re[b] {
    result+=1
  }
}
print(result)