Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim X As String = ReadLine()
        Dim s_cnt, ans As Integer

        For Each v As Char In X
            Select Case v
                Case "S"c
                    s_cnt += 1
                Case "T"c
                    If s_cnt = 0 Then
                        ans += 1
                    Else
                        s_cnt -= 1
                    End If
            End Select
        Next

        ans += s_cnt
        WriteLine(ans)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
