#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
uint32_t getrand() {uint32_t seed = time(NULL);mt.seed(seed);return mt();}
//constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) {if (c)print("Yes"); else print("No");}

template<typename T, T MOD1, T MOD2, T B1, T B2>
struct RollingHash {
	vector<T>hash[2], p[2];
	T MOD[2] = { MOD1,MOD2 };
	T B[2] = { B1,B2 };
	RollingHash(const string &s) {
		int N = s.size();
		for (int k = 0; k < 2; k++) {
			hash[k].assign(N + 1, 0);
			p[k].assign(N + 1, 1);
			for (int i = 0; i < N; i++) {
				hash[k][i + 1] = (hash[k][i] * B[k] + s[i]) % MOD[k];
				p[k][i + 1] = p[k][i] * B[k] % MOD[k];
			}
		}
	}

	//S[l,r)
	pair<T, T>find(int l, int r) {
		T res1 = hash[0][r] + MOD[0] - hash[0][l] * p[0][r - l] % MOD[0];
		res1 = (res1 >= MOD[0]) ? res1 - MOD[0] : res1;
		T res2 = hash[1][r] + MOD[1] - hash[1][l] * p[1][r - l] % MOD[1];
		res2 = (res2 >= MOD[1]) ? res2 - MOD[1] : res2;

		return make_pair(res1, res2);
	}
	T find1(int l, int r) {
		T res1 = hash[0][r] + MOD[0] - hash[0][l] * p[0][r - l] % MOD[0];
		return (res1 >= MOD[0]) ? res1 - MOD[0] : res1;
	}
	T find2(int l, int r) {
		T res2 = hash[1][r] + MOD[1] - hash[1][l] * p[1][r - l] % MOD[1];
		return (res2 >= MOD[1]) ? res2 - MOD[1] : res2;
	}
};
using RH = RollingHash<ll, (ll)1e9 + 7, (ll)1e9 + 9, 1234567, 7654343>;



void solve() {
	//cout << base << endl;
	int N, M; cin >> N >> M;
	string S; cin >> S;
	RH rh(S);
	set<pair<int, int>>st;
	int l = 0, r = 1;
	REP(_, M) {
		string s; cin >> s;
		if (s == "R++")r++;
		else if (s == "R--")r--;
		else if (s == "L++")l++;
		else if (s == "L--")l--;
		pii res = rh.find(l, r);
		st.insert(res);
	}
	cout << st.size() << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}





Measured memory_bytes: 26500