s = input()

s_cnt, t_cnt = 0, 0
ans = 0
for i in range(len(s)):
    if s[i] == "S":
        s_cnt += 1
    else:
        t_cnt += 1
        if i == len(s) - 1 or s[i + 1] == "S":
            ans += min(t_cnt, s_cnt)
            t_cnt = 0
            c_cnt = 0

print(len(s) - ans * 2)