Ejemplo n.º 1
0
        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = false
            };

            new Program().Solve(ss, sw);
            sw.Flush();
        }
Ejemplo n.º 2
0
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var ls = new Stack <char>();
            var rs = new Stack <char>(Console.ReadLine().Reverse());

            while (rs.Count > 0)
            {
                if (ls.Count != 0 && ls.Peek() == 'S' && rs.Peek() == 'T')
                {
                    ls.Pop();
                    rs.Pop();
                }
                else
                {
                    ls.Push(rs.Pop());
                }
            }

            sw.WriteLine(ls.Count);
            //---------------------------------
        }