def main():
    s = input()
    for i in range(10**10000):
        sp = s.split('ST', 1)
        if len(sp) > 1:
            s = sp[0] + sp[1]
        else:
            break
    print(len(s))

if __name__ == '__main__':
    main()