X = input()
N = len(X)
S = N // 2
T = S

con = 0
ans = N

for i in range(N):
  j = i + 1
  if X[i] == "S":
    con += 1
    remain = N - j
    rems = S - con
    remt = remain - rems
    if remt > 0:
      ans -= 2

print(ans)
