using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Solution
{
    class Solution
    {
        static void Main(string[] args)
        {
            string s = System.Console.ReadLine();
            for(int i = 0; i < 100000; i++)
            {
                s = Regex.Replace(s, "ST", string.Empty);
            }
            System.Console.WriteLine(s.Length);
        }

    }
}
