# -*- coding: utf-8 -*-

_input = input().split()
# _input = 'SSTTST'
s = [c for c in _input]
length = len(s)

for i, c in enumerate(s):
    if i < 1:
        continue
    elif length == i + 1:
        break

    couter = 1
    dec = i
    inc = i + couter
    try:
        while s[dec] == 'S' and s[inc] == 'T':
            del s[dec]
            del s[inc]
            couter += 1
            dec = i - couter if 0 < i - couter else 0
            inc = i + couter if length > i + couter else length - 1
    except:
        pass

print(len(s))
