unittest
{
	assert( [ "3 4", "ABC", "A L", "B L", "B R", "A R" ].solve == 2 );
	assert( [ "8 3", "AABCBDBA", "A L", "B R", "A R" ].solve == 5 );
	assert( [ "10 15", "SNCZWRCEWB", "B R", "R R", "E R", "W R", "Z L", "S R", "Q L", "W L", "B R", "C L", "A L", "N L", "E R", "Z L", "S L" ].solve == 3 );
	
	assert( [ "3 4", "ABC", "B L", "A L", "B R", "C R" ].solve == 0 );		// 追加ケース
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto q = 0L;
	input.front.formattedRead!"%s %s"( n, q );
	input.popFront;
	auto s = input.front.to!( dchar[] );
	auto tds = new dchar[ 2 ][ q ];
	foreach( ref td; tds )
	{
		input.popFront;
		auto as = input.front.to!( dchar[] );
		td = [ as[ 0 ], as[ 2 ] ];
	}
	
	// ゴーレムが残る範囲を判定
	s = "!!" ~ s ~ "!!";
	auto l = 2L;
	auto r = n + 1;		// 閉区間表現
	foreach_reverse( td; tds )
	{
		if( td[ 1 ] == 'R' )
		{
			if( s[ r     ] == td[ 0 ] ) r--;
			if( s[ l - 1 ] == td[ 0 ] ) l--;
		}
		else
		{
			if( s[ r + 1 ] == td[ 0 ] ) r++;
			if( s[ l     ] == td[ 0 ] ) l++;
		}
		if( r < l ) break;
	}
	return 1 + r - l;
}
