def problem_p03986(input_data):
    s = "".join(input_data.split("ST"))

    cnts = 0

    cnt = 0

    for i in s:

        if i == "S":

            cnts += 1

        elif cnts > 0:

            cnts -= 1

            cnt += 1

    return len(s) - cnt * 2
