x = raw_input()

y = []
for i in x:
    if len(y) == 0:
        y.append(i)
    elif i == 'S':
        y.append(i)
    elif i == 'T' and y[-1] == 'T':
        y.append(i)
    else:
        y.pop()

print len(y)
