x = input()
s_q = []
t_q = []
for i, v in enumerate(x):
    if v == 'S':
        s_q.append(v)
    else:
        t_q.append(v)
        while len(t_q) > 0 and len(s_q) > 0:
            t_q.pop()
            s_q.pop()
print(len(s_q)+len(t_q))

