using System;

namespace agc005_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string T = Console.ReadLine();
            bool x = true;
            while (x)
            {
                if (T.IndexOf("ST") >= 0)
                {
                    T = T.Replace("ST", null);
                }
                else
                {
                    x = false;
                }
            }
            Console.WriteLine(T.Length);
        }
    }
}