instring = raw_input()

finallen = len(instring)
num_open = 0
for char in instring:
    if (char == 'S'):
        num_open += 1
    elif(num_open > 0):
        num_open -= 1
        finallen -= 2
print finallen