s = raw_input()

#while s.find('ST') > -1:
#    s = ''.join(s.split('ST'))
#
#print len(s)

temp = []
for i in range(len(s)):
    now = s[i]
    if len(temp) == 0:
        temp.append(now)
    elif temp[-1] + now == 'ST':
        temp.pop()
    else:
        temp.append(now)

print len(temp)