using System;

namespace AGC005_A_STring
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string x = Console.ReadLine();
			bool subStrIsCalled = false;
			
			for (int i = 0; i < Math.Pow(10, 10000); i++) {
				for (int j = 0; j < x.Length - 1; j++) {
					if (x.Substring(j, 2) == "ST")
					{
						x = x.Substring(0, j) + x.Substring(j + 2, x.Length - (j + 2));
						subStrIsCalled = true;
						break;
					}
				}
				
				if (!subStrIsCalled)
				{
					break;
				}
				else
				{
					subStrIsCalled = false;
				}
			}
			
			Console.WriteLine(x.Length);
		}
	}
}