using System;

public class Test
{
	public static void Main()
	{
		var S = Console.ReadLine();
		while (true)
		{
			var tmp = S.Replace("ST", "");
			if (tmp == S)
			{
				break;
			}
			else
			{
				S = tmp;
			}
		}
		Console.WriteLine(S.Length);
	}
}