X = input()
N = len(X)

right = N - 1
cnt = 0

for left in range(N - 1):
    if X[left] == 'S':
        while X[right] != 'T':
            right -= 1
        if left < right:
            cnt += 1
print(N - cnt * 2)