program moshnost;
Var
a,b: set of char;
s1,l1,l2,o,itog:integer;
begin
a:=['f','g','t'];
b:=['f','s','r','t'];
l1:=0;
l2:=0;
o:=0;
for s1:=0 to 255 do
begin
if chr(s1) in a then l1:=l1+1;
if chr(s1) in b then l2:=l2+1;
if (chr(s1) in a) and (chr(s1) in b) then o:=o+1;
end;
itog:=l1+l2-o;
writeln (itog);
end.