import sys
input=sys.stdin.readline

def main():
    X = input().strip()

    for i in range(9,-1,-1): # 注: 長さは根拠なし
        # "S..ST..T"
        s = "S"*(2**i) + "T"*(2**i)
        while X.find(s) != -1:
            X = X.replace(s,"")
        # "ST..ST"
        s = "ST"*(2**i)
        while X.find(s) != -1:
            X = X.replace(s,"")
    print(len(X))

if __name__ == '__main__':
    main()
