using System;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int cnt = 0;
        int cnt_max = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'T') { cnt++; }
            else { cnt--; }
            cnt_max = Math.Max(cnt, cnt_max);
        }

        Console.WriteLine(cnt_max);
    }
}
