using System;

namespace ConsoleApplication1
{
    class Program
    {
        public static void Main()
        {
            string StringST = "SSTT";//Console.ReadLine();
            System.Collections.Generic.Stack<string> stcST = new System.Collections.Generic.Stack<string>();

            while (StringST.Length != 0)
            {
                string s = StringST.Substring(0, 1);
                StringST = StringST.Remove(0, 1);

                if (stcST.Count == 0)
                {
                    stcST.Push(s);
                }
                else if (stcST.Peek().Equals("S") && StringST.Substring(0, 1).Equals("T"))
                {
                    stcST.Pop();
                }
                else
                {
                    stcST.Push(s);
                }
            }
            Console.WriteLine(stcST.Count);
        }
    }
}

