def main():
    x = input()
    tmp = x.replace("ST", "")
    for i in range(10**6):
        if x == tmp:
            break
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()