unittest
{
	assert( [ "TSTTSS" ].parse.expand.solve == 4 );
	assert( [ "SSTTST" ].parse.expand.solve == 0 );
	assert( [ "TSSTTTSS" ].parse.expand.solve == 4 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( dchar[] );
	return tuple( x );
}

auto solve( dchar[] x )
{
	auto i = 0L;
	while( i + 1 < x.length )
	{
		if( x[ i .. i + 2 ] == "ST" )
		{
			x = x[ 0 .. i ] ~ x[ i + 2 .. $ ];
			i -= ( 0 <= i - 1 );
		}
		else
		{
			i++;
		}
	}
	return x.length;
}
