def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    x = input()
    while 'ST' in x:
        x = x.replace('ST', '')
    print(len(x))

main()
