console.log((args=>{
  const X = args.trim();
  const L = X.length;
  let s = 0, t = 0;
  for ( let i = 0; i < L; i++ ) {
    if ( X[i] === 'S' ) s++;
    if ( X[i] === 'T' ) {
      if ( s > 0 ) s--;
      else t++;
    }
  }
  return `${s+t}`;
})(require('fs').readFileSync('/dev/stdin','utf8')));
