#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n, q;
    char s[200020], t[200020], d[200020];
    cin >> n >> q;
    cin >> s;
    for (int i = 0; i < q; i++) cin >> t[i] >> d[i];
    
    vector<int> a(n, 0), b(n, 0);
    int x = 0, y = n - 1, xt = 0, yt = 0;
    for (int i = q - 1; i >= 0; i--) {
        if (d[i] == 'L' && s[x] == t[i]) x++;
        if (d[i] == 'R' && x != 0 && s[x - 1] == t[i]) x--;
    }
    for (int i = q - 1; i >= 0; i--) {
        if (d[i] == 'R' && s[y] == t[i]) y--;
        if (d[i] == 'L' && y + 1 != n && s[y + 1] == t[i]) y++;
    }
    
    cout << n - x - (n - 1 - y) << endl;
    
}
