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

namespace atcodetest
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            double dblNum = Math.Pow(10, 10000);
            if(s.Substring(0,1).Equals("S") && s.Substring(s.Length - 1).Equals("T"))
            { s = string.Empty; }
            
            for (int i = 0; i < dblNum;i++)
            {
                s = s.Replace("ST", "");
                if(!s.Contains("ST"))
                { break; }
            }
            Console.WriteLine(s.Length.ToString());
        }
    }
}