Var a,b:array[1..4] of longint;i,j,x,y,k:longint;
Begin
read(x,y);
for i:=1 to 4 do
begin
a[i]:=x mod 10;
x:=x div 10;
end;
for i:=1 to 4 do
begin
b[i]:=y mod 10;
y:=y div 10;
end;
for i:=1 to 3 do
for j:=i+1 to 4 do
if (a[i]=b[j]) then k:=k+1;
writeln(k);
End.