Problem: Given a string of length n s = s1, s2,…, sn and m queries. Each query qk (1 ≤ k ≤ m) is one of four types, "L ++", "L-", "R ++", "R-", and l [for the kth query qk. k] and r [k] are defined below.

* L ++: l [k] = l [k-1] + 1, r [k] = r [k-1]

* L-: l [k] = l [k-1] -1, r [k] = r [k-1]

* R ++: l [k] = l [k-1], r [k] = r [k-1] +1

* R-: l [k] = l [k-1], r [k] = r [k-1] -1




However, l [0] = r [0] = 1.

At this time, how many kinds of character strings are created for m substrings sl [k], sl [k] + 1,…, sr [k] -1, sr [k] (1 ≤ k ≤ m). Answer if you can.

Constraints

* The string s consists of a lowercase alphabet

* 1 ≤ n ≤ 3 x 105

* 1 ≤ m ≤ 3 × 105

* qk (1 ≤ k ≤ m) is one of "L ++", "L-", "R ++", "R-"

* 1 ≤ l [k] ≤ r [k] ≤ n (1 ≤ k ≤ m)

Input

Input is given in the following format

> n m
> s
> q1
> q2
>…
> qm
>

Output

Output the solution of the problem on one line

Examples

Input

5 4
abcde
R++
R++
L++
L--


Output

3


Input

4 6
abab
R++
L++
R++
L++
R++
L++


Output

4


Input

10 13
aacacbabac
R++
R++
L++
R++
R++
L++
L++
R++
R++
L--
L--
R--
R--


Output

11

Solution (in CPP):

Solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

const ll coe[] = {1007, 1009};
const ll mod[] = {(ll)1e9+7, (ll)1e9+9};

ll add(ll a, ll b, ll m) {
	return (a + b) % m;
}
ll mul(ll a, ll b, ll m) {
	return (a * b) % m;
}
ll power(ll x, ll n, ll m) {
	ll res = 1;
	for (ll i = 1; i <= n; i <<= 1) {
		if (i & n) res = mul(res, x, m);
		x = mul(x, x, m);
	}
	return res;
}

ll get_hash(vector<ll>& h, int l, int r, int hid) {
	return mul(add((h[r] - h[l]) % mod[hid], mod[hid], mod[hid]), power(power(coe[hid], l, mod[hid]), mod[hid]-2, mod[hid]), mod[hid]);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N, M; cin >> N >> M;
	string S; cin >> S;
	int l = 0, r = 1;
	vector<ll> h[2];
	REP(i, 2) {
		h[i] = vector<ll>(N+1, 0);
		REP(j, N) {
			h[i][j+1] = add( h[i][j], mul(S[j], power(coe[i], j, mod[i]), mod[i]), mod[i] );
		}
	}
	set<P> s;
	REP(q, M) {
		string Q; cin >> Q;
		if (Q == "R++") {
			++r;
		}
		else if (Q == "R--") {
			--r;
		}
		else if (Q == "L++") {
			++l;
		}
		else if (Q == "L--") {
			--l;
		}
		s.insert( P( get_hash(h[0], l, r, 0), get_hash(h[1], l, r, 1) ) );
	}
	// cout << get_hash(h[0], 0, 1, 0) << endl;
	// cout << get_hash(h[0], 1, 2, 0) << endl;
	// cout << get_hash(h[0], 2, 3, 0) << endl;
	// cout << get_hash(h[0], 3, 4, 0) << endl;
	// cout << get_hash(h[0], 4, 5, 0) << endl;
	cout << s.size() << endl;
}