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

int N, Q;
string s;

int check(int n, vector<char> t, vector<char> d){
    for(int i = 0; i < Q; i++)
    {
        if(s.at(n) == t.at(i)){
            if(d.at(i) == 'L')n--;
            else n++;
        }

        if(n == -1 || n == N)return n;
    }

    return n;
}

int main() {

    cin >> N >> Q;
    cin >> s;

    vector<char> t(Q);
    vector<char> d(Q);

    for(int i = 0; i < Q; i++){
        cin >> t.at(i) >> d.at(i);
    }

    int ans1, ans2;

    int a, b;
    a = 0; b = N;

    while( b-a >= 1){
        int i = (a+b)/2;
        if(check(i, t, d) == -1)a = i+1;
        else b = i;
    }
    ans1 = a;

    a = 0; b = N;
    
    while( b-a >= 1){
        int i = (a+b)/2;
        if(check(i, t, d) == N)b = i;
        else a = i+1;
    }
    ans2 = a;

    cout <<  ans2 - ans1 << endl;
}