using System;

public class Hello
{
    public static void Main()
    {
        var a = Console.ReadLine().Trim();
        while (true)
        {
            var w = a.Replace("ST", "");
            if (w.Length == a.Length) { Console.WriteLine(w.Length); break; }
            else a = w;
        }
    }
}
