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

char t[200005], d[200005];
int n, q;
string s;

int check(int m) {
    for (int i = 0; i < q; i++) {
        if (s[m] == t[i]) {
            if (d[i] == 'L')
                m--;
            else
                m++;
        }
        if (m < 0)
            return 1;
        else if (m >= n)
            return 2;
    }
    return 0;
}

int main() {
    cin >> n >> q;
    cin >> s;
    for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
    int l1 = -1, r1 = n;
    int l2 = -1, r2 = n;
    while (r1 - l1 > 1) {
        int mid = (l1 + r1) / 2;
        if (check(mid) == 1)
            l1 = mid;
        else
            r1 = mid;
    }
    while (r2 - l2 > 1) {
        int mid = (l2 + r2) / 2;
        if (check(mid) == 2)
            r2 = mid;
        else
            l2 = mid;
    }
    cout << max(0, l2 - r1 + 1) << endl;
    return 0;
}
