#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)








int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    char s[200005];
    scanf("%s", s);
    char t[200005], d[200005];
    array<vector<pair<int, char>>, 26> v;
    int l_sum = 0, r_sum = 0;
    for(int i = 0; i < q; i++){
        cin >> t[i] >> d[i];
        v[t[i] - 'A'].push_back({i, d[i]});
        if(d[i] == 'L') l_sum++;
        else r_sum++;
    }
    array<pair<int, int>, 200005> rem;
    for(int i = 0; i < q; i++){
        rem[i] = {l_sum, r_sum};
        if(d[i] == 'L') l_sum--;
        else r_sum--;
    }
    int ans = n;
    for(int i = 0; i < n; i++){
        int now = i, p = 0;
        for(;;){
            if(now < 0 || now >= n){
                ans--;
                break;
            }
            if(now - rem[p].first >= 0 && now + rem[p].second < n){
                break;
            }
            int c = s[now] - 'A';
            int itr = lower_bound(v[c].begin(), v[c].end(), make_pair(p, 'L')) - v[c].begin();
            if(itr >= v[c].size()) break;
            if(v[c][itr].second == 'L') now--;
            else now++;
            p = v[c][itr].first + 1;
        }
    }
    printf("%d\n", ans);
}