X = input()
n = len(X)
cnt, ss, ts = 0, 0, 0
for i in range(n):
    if X[i] == 'S':
        if ts == 0:
            ss += 1
        else:
            cnt += min(ss, ts)*2
            ss = 1
            ts = 0
    else:
        ts += 1
else:
    cnt += min(ss, ts)*2

print(n-cnt)
