#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s, i, m) for(unsigned int i = s; i < m; ++i)
#define REP(i, m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

using namespace std;

int N, Q;
string s;
vector<char> t;
vector<char> d;

bool drop(int index) {
    for (int i = 0; i < Q; ++i) {
        if (s[index] == t[i]) {
            if (d[i] == 'L') {
                index--;
            } else {
                index++;
            }
        }
        if (index < 0 || index >= N) return true;
    }
    return false;
}

int solve() {
    int ok = 0, ng = N;
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;
        if(drop(mid)) {
            ng = mid;
        } else {
            ok = mid;
        }
    }

    int ok1 = ok, ng1 = -1;
    while(abs(ok1 - ng1) > 1) {
        int mid = (int)ceil((ok1 + ng1) / 2.0);
        if(drop(mid)) {
            ng1 = mid;
        } else {
            ok1 = mid;
        }
    }

    int ok2 = ok, ng2 = N;
    while(abs(ok2 - ng2) > 1) {
        int mid = (ok2 + ng2) / 2;
        if(drop(mid)) {
            ng2 = mid;
        } else {
            ok2 = mid;
        }
    }

    return N - (ok1 + (N - 1 - ok2));
}

int main() {
    cin >> N >> Q;
    cin >> s;
    t.resize(Q);
    d.resize(Q);
    REP(i, Q) cin >> t[i] >> d[i];
    cout << solve() << endl;
}