text = raw_input().rstrip()

size = len(text)
import re

words = re.split('(S+)',text)

from itertools import izip

for i in xrange(1,len(words[1:]),2):
  s,t = words[i], words[i+1]
  size -= min(len(s),len(t))*2

print size