#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    vector<char> T(Q), D(Q);
    for (int i = 0; i < Q; i++) cin >> T[i] >> D[i];
    auto simulate = [&](int x) {
        for (int i = 0; i < Q; i++) {
            if (s[x] == T[i]) {
                x += (D[i] == 'L' ? -1 : +1);
                if (x < 0) return -1;
                if (x >= N) return 1;
            }
        }
        return 0;
    };
    int A, B;
    {
        int ok = -1, ng = N;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            (simulate(mid) < 0 ? ok : ng) = mid;
        }
        A = ok;
    }
    {
        int ok = -1, ng = N;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            (simulate(mid) <= 0 ? ok : ng) = mid;
        }
        B = ok;
    }
    cout << (B - A) << endl;
    return 0;
}