#include <iostream>

using namespace std;
int main() {
    int N, Q;
    char s[200001];
    char t[200001];
    char d[200001];
    cin >> N >> Q;
    for(int i=0; i<N; i++) cin >> s[i];
    for (int i=0; i<Q; i++) cin >> t[i] >> d[i];
    
    int head = 0;
    int tail = N-1;
    for (int i=Q-1; i>=0; i--) {
        if (d[i] == 'L') {
            if (s[head] == t[i]) {
                head++;
            }
            if (tail+1 < N && s[tail+1] == t[i]) {
                tail++;
            }
        }
        else {
            if (s[tail] == t[i]) {
                tail--; 
            }
            if (head-1 >= 0 && s[head-1] == t[i]) {
                head--;
            }
        }
    }
    cout << tail - head + 1 << endl;
    return 0;
}

