#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,q,ans=n;
    cin >> n >> q;
    vector<pair<char,int>> v(n);
    for(int i=0;i < n;i++){
        cin >> v.at(i).first;
        v.at(i).second = 1;
    }//input

    for(int j=0;j < q;j++){
        char a,b;
        cin >> a >> b;
        for(int k=0;k < v.size();k++){
            if(v.at(k).first == a){
                if(b == 'L'){
                    if(k !=0){
                    v.at(k-1).second += v.at(k).second;
                    v.at(k).second = 0;
                    }
                    else{
                        ans -= v.at(i).second;
                        v.at(i).second = 0;
                    }
                }

                if(b == 'R'){
                    if(k != n-1){
                    v.at(k+1).second += v.at(k).second;
                    v.at(k).second = 0;
                    }
                    else{
                        ans -= v.at(i).second;
                        v.at(i).second = 0;
                    }
                } 
            }
        }
    }
    cout << ans << endl;
}