s = raw_input()

s_len = len(s)

while True:
    s_len_old = s_len
    s_list = list(s)
    for i in range(len(s_list) - 1):
        if s[i] == 'S' and s[i + 1] == 'T':
            s_len -= 2
            s_list[i] = ''
            s_list[i + 1] = ''
            for j in range(1, i + 1):
                if s_list[i - j] == 'S' and s_list[i + j + 1] == 'T':
                    s_len -= 2
                    s_list[i - j] = ''
                    s_list[i + j + 1] = ''
                else:
                    break

    if s_len_old == s_len:
        break
    else:
        s = ''.join(s_list)

print s_len