X = input()
dp = [0] * (len(X)+1)
dp[1] = 1
S = [X[0]]
for i in range(2, len(X)+1):
    if X[i-1] == 'S':
        S.append('S')
        dp[i] = dp[i-1] + 1
    else:
        if 'S' in S:
            S.remove('S')
            dp[i] = dp[i-1] - 1
        else:
            S.append('T')
            dp[i] = dp[i-1] + 1
print(dp[-1])
