s = list(input())
cnt = 0
while True:
    if s[0] == 'T':
        s.pop(0)
        cnt += 1
    else:
        break
    
while True:
    if s[-1] == 'S':
        s.pop(-1)
        cnt += 1
    else:
        break
        
i = 0
now = 'on'
ans = 0
cs = 0
while i < len(s):
    if s[i] == 'S':
        cs += 1
        now = 'on'
        i += 1
    elif now == 'on' and s[i] == 'T':
        i += cs
        cs = 0
        now = 'off'
    elif now == 'off' and s[i] == 'T':
        cnt += 1
        i += 1
        
    if i >= len(s):
        break
print(cnt)