x=eval(input());c=0

for t in x:c+=t=='S'or(c>0)*-1

print((2*c))
c=0

for x in eval(input()):c+=x=='S'or(c>0)*-1

print((2*c))
x = eval(input())
c = 0
for t in x:
    c += t == "S" or (c > 0) * -1
print((2 * c))

c = 0
for x in eval(input()):
    c += x == "S" or (c > 0) * -1
print((2 * c))

-x = eval(input()) -for t in x: -    c += t == "S" or (c > 0) * -1 +for x in eval(input()): +    c += x == "S" or (c > 0) * -1