X = input()

count = 0

count_s = 0
last_x = ''
for x in X:
    if x == 'S':
        if last_x == 'T':
            count_s = 0
        count_s += 1
    elif x == 'T':
        if count_s > 0:
            count += 1
            count_s -= 1
    last_x = x

count = min(count, 10 ** 10000)
print(len(X) - count * 2)
