 var
   s,t:ansistring;
   i,m,ans,n:longint;
begin
       readln(s);
       n:=length(s);
       m:=0; t:='';
       for i:=1 to n do
       begin
                if(s[i]='T') and (m<>0) and (t[m]='S')then  dec(m)
                else begin inc(m); t:=t+s[i];  end;
       end;
      writeln(m);
end.