x = input()
n = len(x)

checkt = False
checks = False
s = 0
t = 0
for i in range(n-1,-1,-1):
    if(x[i] == 'S'):
        if(checkt):
            s += 1
    else:
        checkt = True

for i in range(n):
    if(x[i] == 'T'):
        if(checks):
            t += 1
    else:
        checks = True

print(n - min(s,t) * 2)
