unittest
{
	assert( [ "BBW" ].parse.expand.solve == 2 );
	assert( [ "BWBWBW" ].parse.expand.solve == 6 );
}



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 s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	auto ans = 0L;
	auto w = ( s[ $ - 1 ] == 'W' ) ? 1L : 0L;
	for( auto i = s.length.signed - 2; 0 <= i; i-- )
	{
		if( s[ i ] == 'B' )
		{
			if( s[ i + 1 ] == 'W' )
			{
				s[ i ] = 'W';
				ans += w;
			}
			else
			{
				w = 0;
			}
		}
		else
		{
			w++;
		}
	}
	return ans;
}
