using System;

namespace agc005_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string T = Console.ReadLine();
            for (int i = 0; i < T.Length / 2 + 1; i++)
            {
                T = T.Replace("ST", "");
            }
            Console.WriteLine(T.Length);
        }
    }
}