    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            List<char> inpt = Reader.ReadLine().ToList();
            int idx = 0;
            int roopEnd = inpt.Count;
            for(int i=0; i<roopEnd; i++) {
                if(idx>=inpt.Count) {
                    break;
                }
                if(inpt.Count <= 1) {
                    break;
                }
                if(idx<0) {
                    idx=0;
                }
                if(inpt[idx] == 'S' && inpt[idx+1] == 'T') {
                    inpt.RemoveAt(idx+1);
                    inpt.RemoveAt(idx);
                    idx--;
                } else {
                    idx++;
                }
            }
            Console.WriteLine(inpt.Count);

        }



        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




SSTTST






";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }