#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define rep(i,n) for(int i=0,i##_len=n;i<i##_len;i++)
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

ull p = 1000000007ull;
signed main(){
  int n, m; cin >> n >> m;
  string s; cin >> s;
  vector<ull> hash(n+1), pow(n+1);
  hash[0] = 0;
  pow[0] = 1;
  rep(i, n){
    hash[i+1] = hash[i] * p + s[i];
    pow[i+1] = pow[i] * p;
  }
  set<ull> res;

  int l = 0, r = 1;
  rep(i,m){
    string q; cin >> q;
    if(q == "R++") r++;
    if(q == "R--") r--;
    if(q == "L++") l++;
    if(q == "L--") l--;
    res.insert(hash[r] - hash[l] * pow[r - l]);
  }
  cout << res.size() << endl;
}