#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];
    }
    int left = 0; int right = n;
    for (int i = q-1; i >= 0; i--) {
        if (d[i] == 'L') {
            if (s[left] == t[i]) left++;
            if (right != n && s[right] == t[i]) right++;
        } else {
            if (s[right-1] == t[i]) right--;
            if (left != 0 && s[left-1] == t[i]) left--;
        }
        if (left == right) break;
    }
    cout << right - left << endl;
    return 0;
}