import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x = input()

    for _ in range(10 ** 5):
        x = x.replace("ST", "")
        x = list(x)
        x = "".join(x)

    print(len(x))


if __name__ == '__main__':
    resolve()
