using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{

    static void Main()
    {
        string S = Console.ReadLine();
       for(int i = 0; i < S.Length / 2; i++)
        {
            S = S.Replace("ST", "");
        }
        Console.WriteLine(S.Length);
    }

}