X = raw_input()

y = []
for n in xrange(len(X)):
    y.append(X[n])

    while (1):
        if len(y) < 2: break
        if y[-2] == 'S' and y[-1] == 'T':
            y.pop()
            y.pop()
        else:
            break

print len(y)