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

public class GFG
{
    static public void Main()
    {
        try
        {
            var n = Console.ReadLine();
            //var input1 = Console.ReadLine().Split(' ');
            //var n = int.Parse(input1[0]);
            //var b = int.Parse(input1[1]);

            /// var aar = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();

            Remove(n);
        }
        catch (Exception ex)
        {
            Console.Write(ex);
        }
    }

    static void Remove(string s)
    {

        var ss = s.ToCharArray();

        for (int i = 0; i < ss.Length-1; i++)
        {
            if (ss[i] == 'S' && ss[i + 1] == 'T')
            {
                ss[i] = ' ';
                ss[i + 1] = ' ';
                ss = string.Join("", ss).Replace(" ", "").ToArray();
                i = 0; ;
            }
           

        }

        
        Console.Write(ss.Length);
    }
}