X = input()
current = None
s = 0
t = 0
ans = 0
for x in X:
    if x == 'S':
        if current != x:
            ans += min(s, t) * 2
            s = t = 0
        s += 1
    else:
        if current != x:
            t = 0
        t += 1
    current = x
ans += min(s, t) * 2
print(len(X) - ans)
