#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);

typedef unsigned long long ull;
const ull B=9973ULL;


int main(){
	ull n,m;
	cin>>n>>m;
	string s;
	cin>>s;
	ull h=s[0];
	set<ull> st;
	ull l=0,r=0;
	ull invB=9063375710536127837ULL;
	ull curB=1;
	for(ull i=0;i<m;i++){
		string q;
		cin>>q;
		if(q=="R++"){
			r++;
			h=h*B+s[r];
			curB*=B;
		}
		if(q=="L++"){
			h-=curB*s[l];
			l++;
			curB*=invB;
		}
		if(q=="R--"){
			h=(h-s[r])*invB;
			r--;
			curB*=invB;
		}
		if(q=="L--"){
			l--;
			curB*=B;
			h+=curB*s[l];
		}
		st.insert(h);
	}
	cout<<st.size()<<endl;
}