import numpy as np
def s():
    return raw_input()
def li():
    return map(int,raw_input().split())

st = []
X = list(s())
N = len(X)
st.append(X[0])
X.pop(0)
#for i in range(len(X)-2):
for i in range(N-1):
    st.append(X[0])
    X.pop(0)
    if len(st) >= 2:
        if st[-1] == 'T' and st[-2] == 'S':
            st.pop()
            st.pop()
print len(st)
