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
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

struct HashData {
	int h1, h2;
	bool operator==(const HashData& rhs) const {
		return h1 == rhs.h1 && h2 == rhs.h2;
	}
	bool operator!=(const HashData& rhs) const { return !(*this == rhs); }
};

class RollingHash {
	template<int B, int M>
	class RollingHashPart {
	private:
		size_t len;
		std::vector<int> pow_b, hash;
	public:
		RollingHashPart() {}
		template<typename T>
		RollingHashPart(const T& s) : len(s.size()), pow_b(s.size() + 1), hash(s.size() + 1) {
			pow_b[0] = 1;
			hash[0] = 0;
			for (int i = 0; i < len; i++) {
				pow_b[i + 1] = (ll)pow_b[i] * B % M;
				hash[i + 1] = ((ll)hash[i] * B + s[i]) % M;
			}
		}
		// [l, r)
		int get(int l, int r) const {
			int res = (hash[r] - (ll)hash[l] * pow_b[r - l]) % M;
			if (res < 0) res += M;
			return res;
		}
	};
public:
	RollingHashPart<1033, 1000000007> rh1;
	RollingHashPart<6037, 999999937> rh2;
 
	RollingHash() {}
	template<typename T> RollingHash(const T & s) : rh1(s), rh2(s) {}
	// [l, r)
	HashData get(int l, int r) const {
		return (HashData){ rh1.get(l, r), rh2.get(l, r) };
	}

	lpair getPair(int l, int r) const {
		return make_pair(rh1.get(l,r) , rh2.get(l, r));
	}
	// [l1, r1), [l2, r2)
	int lcp(const RollingHash & rhs, int l1, int r1, int l2, int r2) const {
		int lb = 0, ub = std::min(r1 - l1, r2 - l2) + 1;
		while (ub - lb > 1) {
			int md = (lb + ub) >> 1;
			(get(l1, l1 + md) == rhs.get(l2, l2 + md) ? lb : ub) = md;
		}
		return lb;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	cin >> N >> M;
	string S;
	cin >> S;
	RollingHash rh(S);
	ll lv = 0, rv = 0;
	ll ans = 0;
	map<lpair, ll> mp;
	rep(i,0,M){
		string q;
		cin >> q;
		if(q == "R++"){
			rv++;
		}else if(q == "R--"){
			rv--;
		}else if(q == "L++"){
			lv++;
		}else{
			lv--;
		}
		lpair d = rh.getPair(lv, rv+1);
		if(mp[d] == 0){
			ans++;
			mp[d]++;
		}
	}
	print(ans);
	
	
}
