#include<iostream>
#include<vector>
#include<set>
using namespace std;

typedef unsigned long long ll;
ll B=100000007ULL;
ll b[300002];
ll h[300002];
set<ll> s;
int main(){
    int n,m;
    string str,q;
    cin>>n>>m>>str;
    
    b[0]=1;
    h[0]=str[0];
    for(int i=1;i<str.length();i++){
        b[i]=b[i-1]*B;
        h[i]=h[i-1]*B+str[i];
    }
    
    int l=0,r=0;
    for(int i=0;i<m;i++){
        cin>>q;
        if(q=="L++"){
            l++;
        }
        else if(q=="L--"){
            l--;
        }
        else if(q=="R++"){
            r++;
        }
        else if(q=="R--"){
            r--;
        }
        ll lr=b[r-l+1]*h[l-1]-h[r];
//        cout<<"b[r-l+1]: "<<b[r-l+1]<<"      h[l-1]: "<<h[l-1]<<"    h[r]: "<<h[r]<<endl;
//        cout<<"l: "<<l<<"    r: "<<r<<"    lr: "<<lr<<endl<<endl;;
        s.insert(lr);
    }
    cout<<s.size()<<endl;
    return 0;
}