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();
            Stack<char> stack = new Stack<char>();

            foreach(var c in X)
            {
                if(c == 'T')
                {
                    if(stack.Count > 0 && stack.Peek() == 'S')
                    {
                        stack.Pop();
                    }
                    else
                    {
                        stack.Push(c);
                    }
                }
            }

            Console.WriteLine(stack.Count);
            
        }
    }
}
