using System;
class Program
{
    static void Main(string[] args)
    {
        string x = Console.ReadLine();
        for(int i = 0; i < x.Length - 1; i++)
        {
            if (i < 0) i = 0;
            if (x[i] == 'S' && x[i+1] == 'T')
            {
                x = x.Remove(i, 2);
                i -= 2;
            }
        }
        Console.WriteLine(x.Length);
    }
}