import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = list(input())
length = len(X)

cur = 0
cnt = 0
for i in range(length):
    cur = max(cur, i+1)
    x = X[i]
    if x=='S':
        while cur<length:
            v = X[cur]
            if v=='T':
                cnt += 2
                break
            cur += 1
print(length-cnt)
    