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

const int N = 200000 + 5;

char str[N];
struct Node{
    char c[2], d[2];
}node[N];

int main ()
{
    int n, q;
    cin >> n >> q >> str + 1;
    for (int i = 1; i <= q; ++i) cin >> node[i].c >> node[i].d;
    int ans1 = 0, ans2 = 0;
    for (int i = q; i >= 1; --i) {
        if (ans1 != n) {
            if (node[i].c[0] == str[ans1 + 1] && node[i].d[0] == 'L') {
                ++ans1;
            }
            else if (ans1 && node[i].c[0] == str[ans1] && node[i].d[0] == 'R'){
                --ans1;
            }
        }
        if (ans2 != n) {
            if (node[i].c[0] == str[n - ans2] && node[i].d[0] == 'R') {
                ++ans2;
            }
            else if (ans2 && node[i].c[0] == str[n - ans2 + 1] && node[i].d[0] == 'L') {
                --ans2;
            }
        }
    }
    cout << n - min(n, ans1 + ans2) << endl;
    return 0;
}
