# A_String
s=input()
from itertools import groupby
gr=groupby(list(s))
c=[]
for k,g in gr:
  c.append(len(list(g)))
n=len(c)
if n==1:
  print(0)
  exit(0)
ans=0
s_cnt=0
if s[0]=="S":
  if n%2==1:
      n-=2
  for i in range(n):
    if i%2==0:
      t=min(s_cnt+c[i],c[i+1])
      s_cnt=0
      s_cnt+=c[i]-t
      ans+=2*t
else:
  if n%2==1:
      n-=1
  else:
      n-=2
  for i in range(n):
    if i%2==1:
      t=min(s_cnt+c[i],c[i+1])
      s_cnt=0
      s_cnt+=c[i]-t
      ans+=2*t
print(len(s)-ans)     

