#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
#include <bitset>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

class RollingHash {
public:
	typedef long long int_type;
	typedef tuple<int_type, int_type, int_type> hash_type;

	int_type base1;
	int_type base2;
	int_type base3;
	int_type mod1;
	int_type mod2;
	int_type mod3;
	vector<int_type> hash1;
	vector<int_type> hash2;
	vector<int_type> hash3;
	vector<int_type> pow1;
	vector<int_type> pow2;
	vector<int_type> pow3;
	RollingHash() : base1(1009), base2(1007),base3(1010101), mod1(1000000007), mod2(1000000009),mod3(998244353) {}
	void init(const string &s) {
		ll n = s.size();
		hash1.assign(n + 1, 0);
		hash2.assign(n + 1, 0);
		hash3.assign(n + 1, 0);
		pow1.assign(n + 1, 1);
		pow2.assign(n + 1, 1);
		pow3.assign(n + 1, 1);
		for (ll i = 0; i < n; i++) {
			hash1[i + 1] = (hash1[i] * base1 + s[i]) % mod1;
			hash2[i + 1] = (hash2[i] * base2 + s[i]) % mod2;
			hash3[i + 1] = (hash3[i] * base3 + s[i]) % mod3;
			pow1[i + 1] = pow1[i] * base1 % mod1;
			pow2[i + 1] = pow2[i] * base2 % mod2;
			pow3[i + 1] = pow3[i] * base3 % mod3;
		}
	}

	hash_type get(ll l, ll r) {
		int_type t1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
		int_type t2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
		int_type t3 = ((hash3[r] - hash3[l] * pow3[r - l]) % mod3 + mod3) % mod3;
		return make_tuple(t1, t2, t3);
	}

	void add(string &t) {
		ll old_len = hash1.size();
		hash1.resize(old_len + t.size());
		hash2.resize(old_len + t.size());
		hash3.resize(old_len + t.size());
		pow1.resize(hash1.size());
		pow2.resize(hash1.size());
		pow3.resize(hash1.size());
		for (ll i = 0; i < t.size(); i++) {
			hash1[old_len + i] = (hash1[old_len + i - 1] * base1 + t[i]) % mod1;
			hash2[old_len + i] = (hash2[old_len + i - 1] * base2 + t[i]) % mod2;
			hash3[old_len + i] = (hash3[old_len + i - 1] * base3 + t[i]) % mod3;
			pow1[old_len + i] = pow1[old_len + i - 1] * base1 % mod1;
			pow2[old_len + i] = pow2[old_len + i - 1] * base2 % mod2;
			pow3[old_len + i] = pow3[old_len + i - 1] * base3 % mod3;
		}
	}
};


int main()
{
	ll N, M;
	cin >> N >> M;
	string s;
	cin >> s;
	RollingHash rol;
	rol.init(s);
	vector<ll> l(M + 1, 0), r(M + 1, 0);
	l[0] = 1;
	r[0] = 1;
	set<tuple<ll, ll,ll >> se;
	for (ll i = 0; i < M; i++) {
		string a;
		cin >> a;
		if (a == "L++") {
			l[i + 1] = l[i] + 1;
			r[i + 1] = r[i];
		}
		else if (a == "L--") {
			l[i + 1] = l[i] - 1;
			r[i + 1] = r[i];
		}
		else if (a == "R++") {
			l[i + 1] = l[i];
			r[i + 1] = r[i] + 1;
		}
		else {
			l[i + 1] = l[i];
			r[i + 1] = r[i] - 1;
		}
		se.insert(rol.get(l[i + 1] - 1, r[i + 1]));
	}

	cout << se.size() << endl;
	return 0;
}



Measured memory_bytes: 40492