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

x = input()

frag = True
while frag:
    frag = False
    if x[0: 2] == "ST":
        x = x[2:]
        frag = True
        continue
    for i in range(1, len(x)):
        if x[i: i+2] == "ST":
            x = x[0: i] + x[i+2:]
            frag = True
            break

print(len(x))
