#include<bits/stdc++.h>
using namespace std;

int main (){

int N, Q;
string S;
cin >> N >> Q >> S;

for(int i=0;i<N;i++) 

int n[N] = 1;

vecter<vecter<char>> a(Q, vecter<char>(2));

for(int i=0;i<Q;i++){
cin >> a.at(i).at(0) >> a.at(i).at(1);
}
int ans = N;
for(int i=0;i<Q;i++){
for(int j=0;j<N;j++){
if(a.at(i).at(0) == S.at(j)){
if(a.at(i).at(1) == 'R'){
if(a.at(i).at(0) == S.at(N-1)){
ans -= n[N-1];
n[N-1] = 0;
}
else{
n[j+1] += n[j];
n[j] = 0;
}
}
else{
if(a.at(i).at(0) == S.at(0)){
ans -= n[0];
n[0] = 0;
}
else{
n[j-1] += n[j];
n[j] = 0;
}
}
}
}
cout << ans << endl;
}
