var   s:ansistring;   i,sum,cnt:longint;
begin
    readln(s);
    for i:=1 to length(s) do
      begin 
          if s[i]='S' then inc(sum);
            if s='T' then 
              begin
                if (sum<>0)then begin dec(sum);inc(cnt,2);end;
              end;
      end;
   writeln(length(s)-cnt);
end.