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

namespace AGC005STing
{
    class Program
    {
        static void Main(string[] args)
        {
            string X = Console.ReadLine();
            StringBuilder sb = new StringBuilder(X);
            int i = 0;
            while (i < sb.Length - 1)
            {
                if (sb[i] == 'S' && sb[i + 1] == 'T')
                {
                    sb.Remove(i, 2);
                    //Console.WriteLine("i=" + i);
                    //Console.WriteLine(sb);

                    if (i >= 1)
                        i--;
                }
                else
                {
                    i++;
                }
            }

            Console.WriteLine(sb.Length);
            //Console.WriteLine(sb);
        }
    }
}
