using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        var X = new StringBuilder(Console.ReadLine());
        while (true)
        {
            int n = X.ToString().IndexOf("ST");
            if (n >= 0)
            {
                X.Remove(n, 2);
            }
            else
            {
                Console.WriteLine(X.Length);
                break;
            }
        }
    }
}
