using System;
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            while (s.Contains("SSTT")) { s = s.Replace("SSTT", ""); }
            while (s.Contains("ST")){ s = s.Replace("ST", "");}
            Console.WriteLine(s.Length.ToString());
        }
    }
