X = list(input())

S_count = 0
ans = 0
for i in range(len(X)):
    if X[i] == 'S':
        S_count += 1
    else:
        if S_count:
            ans += 2
            S_count -= 1

print(len(X)-ans)
c6d1ecf5646ef2cb8d6e1608267d2fe3b2adfcc5
<mask token>

<mask token>
for i in range(len(X)):
    if X[i] == 'S':
        S_count += 1
    elif S_count:
        ans += 2
        S_count -= 1
print(len(X) - ans)

X = list(input())
S_count = 0
ans = 0
for i in range(len(X)):
    if X[i] == 'S':
        S_count += 1
    elif S_count:
        ans += 2
        S_count -= 1
print(len(X) - ans)

X = list(input())

S_count = 0
ans = 0
for i in range(len(X)):
    if X[i] == 'S':
        S_count += 1
    else:
        if S_count:
            ans += 2
            S_count -= 1

print(len(X)-ans)