import itertools
X = input().strip()

continuous_S = 0
continuous_T = 0
ans = len(X)

for key, value in itertools.groupby(X):
    if key == 'S':
        continuous_S = len(list(value))
    else:
        continuous_T = len(list(value))
        ans -= min(continuous_S, continuous_T) * 2

print(ans)