X = list(input())
now = 0
while now < len(X) - 1:
    if X[now] == 'S' and X[now + 1] == 'T':
        for _ in range(2):
            X.pop(now)
        now = max(0, now - 1)
    else:
        now += 1
print(len(X))