x = input()

ans = len(x)
tmp_s = 0
mae = 1

for i in range(len(x)):
    if x[i] == 'S':
        if mae == 0:
            tmp_s = 1
        tmp_s += 1
    elif tmp_s > 0:
        ans -= 2
        tmp_s -= 1
        mae = 0
        
print(ans)