using System;
class a
{
	static void Main()
	{
		string s = Console.ReadLine();
    int n = s.Length;
		int a = s.Length;

    for(int i = 0; i < n; i++)
    {
      if(s[i] == 'S' && s[i+1] == 'T') a -= 2;
    }
		Console.WriteLine(a);
	}
}