from collections import deque

X = input()

ret = deque([X[0]])
for i in range(1, len(X)):
    x = X[i]
    if x == 'S':
        ret.append(x)
    else:
        if ret[-1] == 'S':
            ret.pop()
        else:
            ret.append(x)
print(len(ret))
