program substring
  implicit none
  character(len=3) s,t
  character(len=1) s1,s2,s3,t1,t2,t3
  integer :: c = 0, i
  
  read(*,*)s
  read(*,*)t
  s1 = s(1)
  s2 = s(2)
  s3 = s(3)
  t1 = t(1)
  t2 = t(2)
  t3 = t(3)
  if (s1 == t1) then
      c = c + 1
  end if
  if (s2 == t2) then
      c = c + 1
  end if
  if (s3 == t3) then
      c = c + 1
  end if
  write(*,*)c
end program