x = input()

subt_num = 0
s_t_num = [0, 0]
s_t_flag = [0, 0]

for i in range(len(x)):
    if x[i] == 'S':
        if s_t_flag[0] == 1:
            pass
        else:
            subt_num += min(s_t_num)
            s_t_num = [0, 0]
            s_t_flag = [1, 0]
        s_t_num[0] += 1
    else:
        if s_t_flag[1] == 1:
            pass
        else:
            s_t_flag = [0, 1]
        s_t_num[1] += 1
    
if s_t_flag[1] == 1:
    subt_num += min(s_t_num)
    # print(i, subt_num)

print(len(x) - subt_num * 2)