def s():
    return raw_input()
def li():
    return map(int,raw_input().split())
X = s()
while X.find("ST") >= 0:
    p = X.find("ST")
    X = list(X)
    del X[p]
    del X[p]
    X = ''.join(X)
print len(X)