using System;

class Program {
    static void Main(string[] args) {
        string s = Console.ReadLine(), a;
        int d = s.IndexOf("ST");
        while(d >= 0) {
            a = s.Substring(0, d) + s.Substring(d + 2);
            s = string.Copy(a);
            d = s.IndexOf("ST");
        }
        Console.WriteLine(s.Length);
    }
}