#include <iostream>

using namespace std;

string s;
int n, q;
char c[200005], d[200005];

bool probaj(int x, bool p){
	for(int i = 0 ; i < q ; ++i){
		if(s[x] == c[i]){
			if(d[i] == 'L'){
				x--;
			}
			else{
				x++;
			}
			if(x <= 0 && !p)
				return 1;
			if(x > n && p)
				return 1;
		}
	}
	return 0;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> q;
cin >> s;
s = "$" + s + "$";
for(int i = 0 ; i < q ; ++i){
	cin >> c[i] >> d[i];
}
int l = 1, r = n;
while(l <= r){
	int mid = (l + r) / 2;
	if(!probaj(mid, 0)){
		r = mid - 1;
	}
	else{
		l = mid + 1;
	}
}
//cout << l << ' ' << r << endl;
int sol = r;
l = 1;
r = n;
while(l <= r){
	int mid = (l + r) / 2;
	if(!probaj(mid, 1)){
		l = mid + 1;
	}
	else{
		r = mid - 1;
	}
}
sol += (n + 1 - l);
sol = n - sol;
cout << sol << endl;

return 0;
}

