x = input()

s, t = 0, 0
ols = 0
cnt = 0
for i in x:
  if i == "S":
    cnt += min(ols,t)
    t = 0
    s += 1
  else:
    if s > 0:
     ols = s
    t += 1
    s = 0
cnt += min(ols,t)
print (len(x)-cnt*2)