import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, = map(int, input().split())
S = list(input().strip())

t = 0
s = 0
for i in range(len(S)):
    if S[i] == "T":
        t += 1
    else:
        break

for i in reversed(range(len(S))):
    if S[i] == "S":
        s += 1
    else:
        break

m = len(S) // 2

print(s + t + abs((m - s) - (m - t)))