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

class Program
{
    static void Main(string[] args)
    {
        var chars = Console.ReadLine().ToList();
        
        for (int i = 0; i < 100000; i++)
        {
            for (int j = 0; j < chars.Count - 1; j++)
            {
                if (chars[j] == 'S' && chars[j+1] == 'T')
                {
                    chars.RemoveAt(j + 1);
                    chars.RemoveAt(j);
                    break;
                }
            }
        }
        
        Console.WriteLine(chars.Count);
    }
}