s = input()
m = [{"char": c, "exists": True, "go_to_when_deleted": idx - 1} for idx, c in enumerate(s)]
for idx in range(0, len(s) - 1):
    jdx = idx
    while not m[jdx]["exists"]:
        jdx = m[jdx]["go_to_when_deleted"]
    if m[jdx]["char"] + m[idx + 1]["char"] == "ST":
        m[jdx]["exists"] = False
        m[idx+1]["exists"] = False
        m[idx+1]["go_to_when_deleted"] = m[jdx]["go_to_when_deleted"]
print(len("".join([c['char'] for c in m if c["exists"]])))