using System;
using System.Collections.Generic;

namespace agc005_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Stack<char> stack = new Stack<char>();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'S')
                {
                    stack.Push('S');
                }
                else
                {
                    if (stack.Peek() == 'S')
                    {
                        stack.Pop();
                    }
                    else
                    {
                        stack.Push('T');
                    }
                }
            }
            Console.WriteLine(stack.Count);
        }
    }
}