import sys
input = sys.stdin.readline


def main():
    X = input().rstrip()

    ans = len(X)
    s_seq = 0
    t_seq_to_del = 0
    for s in X:
        if s == "S":
            # (S,T) --> S
            s_seq += 1
        else:
            # S --> T
            if s_seq > 0:
                t_seq_to_del = s_seq
                s_seq = 0
            # (S,T) --> T
            if t_seq_to_del > 0:
                t_seq_to_del -= 1
                ans -= 2
    print(ans)


if __name__ == "__main__":
    main()
