#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, Q;
string s;

int main() {
    cin >> N >> Q >> s;
    vector<char> t(Q), d(Q);
    for (int i = 1; i < Q + 1; i++) {
        cin >> t[Q - i] >> d[Q - i];
    }
    int left = 0, right = N - 1;
    for (int i = 0; i < Q; i++) {
        if (t[i] == s[left] && d[i] == 'L') {
            left++;
            if (left > N - 1) break;
        } else if (left > 0 && t[i] == s[left - 1] && d[i] == 'R') {
            left--;
        }
        
        if (t[i] == s[right] && d[i] == 'R') {
            right--;
            if (right < 0) break;
        } else if (right < N - 1 && t[i] == s[right + 1] && d[i] == 'L') {
            right++;
        }
    }
    cout << max(right - left + 1, 0) << endl;
}
