using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        var st = "ST";
        while (str.IndexOf(st)!=-1)
        {
            var i=str.IndexOf(st);
            str = str.Remove(i, 2);
        }
        WriteLine(str.Length);
    }
}
