#include<bits/stdc++.h>
/**/

using namespace std;


int main(){
	long long int N, Q;
	cin >> N >> Q;
	auto now = vector<long long int>(N, 1);
	string S;
	cin >> S;

	vector<pair<char, char>>Query(Q);
	for( size_t i = 0; i < Q; i++ ){
		cin >> Query[i].first >> Query[i].second;
	}
	long long int begin = -1, end = N;
	for( auto now = Query.rbegin(); now < Query.rend(); now++ ){
		auto ope = *now;
		if( 0 <= begin + 1 && begin + 1 < N&& ope.first == S[begin + 1] && ope.second == 'L' ){
			begin++;
		} else if( 0 <= begin && begin < N&&  ope.first == S[begin] && ope.second == 'R' ){
			begin--;
		}

		if( 0 <= end && end < N&& ope.first == S[end] && ope.second == 'L' ){
			end++;
		} else if( 0 <= end - 1 && end - 1 < N&&  ope.first == S[end - 1] && ope.second == 'R' ){
			end--;
		}
		if( begin + 1 == end ){
			break;
		}
	//cout << begin << " " << end << endl;
	}
	cout << end - begin - 1 << endl;
}
