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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string X = Console.ReadLine();
            char[] x = X.ToArray();
            while (true)
            {
                var rmidx = x.Take(x.Length-1).Select((f, i) => new { f,i}).Where(f => f.f == 'S' && x[f.i+1] == 'T').Select(f=>f.i);
                if (rmidx.Count() == 0)
                    break;
                x = x.Where((f, i) => rmidx.Contains(i) == false && rmidx.Contains(i-1) == false).ToArray();
            }
            Console.WriteLine(x.Length);
        }
    }
}
