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

int main(){
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<pair<char, char>> td(Q);
    for(int i=0; i<Q; i++)
        cin >> td[i].first >> td[i].second;

    reverse(td.begin(), td.end());

    int l = -1, r = N;
    for(auto x : td){
        if(x.second == 'L'){
            if(s[l+1] == x.first)
                l++;
            if(r < N && s[r] == x.first)
                r++;
        }else{
            if(s[r-1] == x.first)
                r--;
            if(l >= 0 && s[l] == x.first)
                l--;
        }
        if(l == r-1) break;
    }
    int ans = N-(l+1+N-r);
    cout << ans << endl;
    return 0;
}