s = input()[::-1]
# 逆順にして"TS"を探す
TT = 0
SS = 0
tmp = 0
res = len(s)


for i in s:
    if i == "T":
        if tmp == "S":
            res -= 2*min(TT, SS)
            TT = 0
            SS = 0
        tmp = "T"
        TT += 1
    else:
        tmp = "S"
        SS += 1
res -= 2*min(TT, SS)
print(res)