#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s;
  int l = 0, r = 1;
  vector< set<int> > L(n+1);
  for(int i = 0; i < m; ++i){
    cin >> t;
    if(t == "R++"){
      ++r;
    }
    if(t == "R--"){
      --r;
    }
    if(t == "L++"){
      ++l;
    }
    if(t == "L--"){
      --l;
    }
    L[r-l].insert(l);
  }
  int ans = 0;
  for(int i = 1; i <= n; ++i){
    set<string> S;
    for(set<int>::iterator itr = L[i].begin(); itr != L[i].end(); ++itr){
      S.insert(s.substr(*itr,i));
    }
    ans += S.size();
  }
  cout << ans << endl;
  return 0;
}