import std.stdio, std.string, std.conv;

void main() {
    string s = readln.chomp;
    string t = readln.chomp;
    int cnt;
    foreach (i; 0 .. 3) {
        if (s[i] == t[i]) ++cnt;
    }
    cnt.writeln;
}