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


namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			 
            string s = Console.ReadLine();

            while(true)
            {
                s = s.Replace("ST", "");
                if (!s.Contains("ST")) break;
            }
            Console.WriteLine(s.Length);
		}				 
	}
}