using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoderGC005 {
  class AtCoderGC005 {
    static void Main(string[] args) {
      new AtCoderGC005().solveA();
    }

    private void solveA() {
      var s = Console.ReadLine();
      var h = "ST";
      int len = s.Length;

      while (s.Length > 0) {
        int index = s.IndexOf(h);
        //s = (index < 0) ? s : s.Remove(index, h.Length);
        if (index < 0)
          break;
        else
          s = s.Remove(index, h.Length);
      }      
      Console.WriteLine(s.Length);
    }//end.

  }
}
