#include <iostream>
using namespace std;
char t[200100], d[200100];
string s;
int n, q;

char sim(int p) {
    for (int i = 0; i < q; i++) {
        if (s[p] == t[i]) p += (d[i] == 'L' ? -1 : 1);
        if (p < 0) return 'L';
        if (p >= n) return 'R';
    }
    return 0;
}

int main() {
    cin >> n >> q;
    cin >> s;
    for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
    int ok, ng;
    for (ok = -1, ng = n; ng - ok > 1; ) {
        int m = (ok + ng) / 2;
        char r = sim(m);
        if (r == 'L') ok = m;
        else ng = m;
    }
    int L = ok;
    for (ok = n, ng = -1; ok - ng > 1; ) {
        int m = (ok + ng) / 2;
        char r = sim(m);
        if (r == 'R') ok = m;
        else ng = m;
    }
    int R = ok;
    cout << R - L - 1 << endl;
}
