#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    char t[Q]; char d[Q]; for (int i = 0; i < Q; ++i) cin >> t[i] >> d[i];
    
    map<char, vector<int>> m;
    for (int i = 0; i < N; ++i) m[S[i]].push_back(i);
    
    vector<int> s(N, 1);
    
    for (int i = 0; i < Q; ++i) {
        for (int j = 0; j < m[t[i]].size(); ++j) {
            index = m[t[i]][j];
            if (s[index] > 0) {
                int x =s[index];
                s[index] -=x;
                if (d[i] == 'R' && index != N-1) s[index + 1] += x;
                if (d[i] == 'L' && index != 0) s[index - 1] += x;
            }
        }
    }
  
    int res = 0; 
    for (int i = 0; i < N; ++i) res += s[i];
    cout << res << endl;
}