 var
   s:ansistring;
   x:longint;
begin
       readln(s);
       while(true) do
        begin
                x:=pos('ST',s);
                if(x=0)then break;
                delete(s,x,2);

        end;
      writeln(length(s));
end.