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