# coding: utf-8
X = input()
tmp = " "
cnt = 0
for x in X:
    if x == "S":
        tmp += x
        cnt += 1
    else:
        if tmp[-1]=="S":
            cnt -= 1
        else:
            tmp += x
            cnt += 1
print(cnt*2)