s = raw_input()
c = len(s)
l = 0
was_es = True
for i in xrange(len(s)):
    if s[i] == "S":
        if was_es == True:
            l += 1
        was_es = True
    else:
        if l > 0:
            l -= 1
            c -= 2
print c