using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //test();
            answer();
            Console.ReadLine();
        }

        static void answer()
        {
            string s = Console.ReadLine();
            string ss = s;
            for (int i = 0; i < 100001; i++)
            {
                s = deleteST(s);
                if ((s.Length == 0) || (s == ss)) { break; }
                ss = s;
            }
            Console.WriteLine(s.Length);

        }

        static void test()
        {
            string s;
            s =deleteST("ST");
            Console.WriteLine(s);
        }

        static string deleteST(string s)
        {
            string ans;
            int i;
            i = s.IndexOf("ST");
            if (i > -1) { ans = s.Substring(0, i) + s.Substring(i + 2); }
            else
            { ans = s; }

            return ans;
        }
    }
}
