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

int main(){
    int n, q;
    cin >> n >> q;
    vector<char> c;
    for (int i = 0; i < n; i++) {
        char x; cin >> x;
        c.push_back(x);
    }
    struct magic { char x,y; } m[q];
    for (int i = 0; i < q; i++) {
        char x, y;
        cin >> x >> y;
        m[i].x = x;
        m[i].y = y;
    }
    int l = 1, r = n;
    for (int i = q - 1; i >= 0; i--) {
        if (m[i].y == 'L') {
            if (c[l-1] == m[i].x) l++;
            if (r != n && c[r] == m[i].x) r++;
        } else {
            if (c[r-1] == m[i].x) r--;
            if (l != 1 && c[l-2] == m[i].x) l--;
        }
    }
    cout << r - l + 1 << endl;
    return 0;
}
