using System;
namespace practice
{
    class Program
    {
        static void Main(string[] args)
        {
            string st = Console.ReadLine();
            int length = 0;
            while (true)
            {
                int find = st.IndexOf("ST");
                if (find < 0)
                {
                    length = st.Length;
                    Console.WriteLine(length);
                    break;
                }
                st=st.Remove(find,2);
            }
        }
    }
}
