ans = 0
cnt_s = cnt_t = 0

for c in s:
    if c == 'S':
        cnt_s += 1
    else:
        cnt_t += 1
    if cnt_t > cnt_s:
        ans += cnt_s
        cnt_s = cnt_t = 0
ans += cnt_s
print(len(s) - ans*2)