X = input()
ans = len(X)
sc = 0
for x in X:
    if x == "S":
        sc += 1
    elif sc > 0:
        sc -= 1
        ans -= 2
print(ans)

e3296a0a8467d22c59221945f7012f83a26c73b8
<mask token>

<mask token>
for x in X:
    if x == 'S':
        sc += 1
    elif sc > 0:
        sc -= 1
        ans -= 2
print(ans)

X = input()
ans = len(X)
sc = 0
for x in X:
    if x == 'S':
        sc += 1
    elif sc > 0:
        sc -= 1
        ans -= 2
print(ans)

X = input()
ans = len(X)
sc = 0
for x in X:
    if x == "S":
        sc += 1
    elif sc > 0:
        sc -= 1
        ans -= 2
print(ans)
