var s:ansistring;
i:longint;
begin
//assign(input,'str.in');reset(input);
//assign(output,'str.out');rewrite(output);
readln(s);
i:=length(s);
while i>=3 do
  begin
  if s[i-1]+s[i]='ST' then
    begin
    delete(s,i-1,2);
    i:=i-1;
    end;
  i:=i-1;
  end;
if (s[1]+s[2]='ST') and (length(s)=2) then
  writeln(0)
else
  begin
  while pos('ST',s)>0 do
    delete(s,pos('ST',s),2);
  writeln(length(s));
  end;
close(input);close(output);
end.
