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
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

struct RollingHash{
  const LL B1, B2, M1, M2;
  vector<LL> hash1, hash2, pow1, pow2;
  RollingHash(string& str): B1(1009), B2(1007), M1(1000000007), M2(1000000009){
	int N = str.size();
	hash1.assign(N+1,0);
	hash2.assign(N+1,0);
	pow1.assign(N+1,1);
	pow2.assign(N+1,1);

	for(int i=0;i<N;++i){
	  hash1[i+1] = (hash1[i] + str[i]) * B1 % M1;
	  hash2[i+1] = (hash2[i] + str[i]) * B2 % M2;
	  pow1[i+1] = pow1[i] * B1 % M1;
	  pow2[i+1] = pow2[i] * B2 % M2;
	}
  }

  // [l,r), 0 <= l < r <= n
  pair<LL,LL> hash(int l, int r){
	pair<LL,LL> res;
	res.first = ((hash1[r] - hash1[l] * pow1[r-l]) % M1 + M1) % M1;
	res.second = ((hash2[r] - hash2[l] * pow2[r-l]) % M2 + M2) % M2;
	return res;
  }
};

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  string S; cin >> S;
  RollingHash rh(S);
  map<int, set<int>> mem;
  int l = 0, sz = 1;
  while(M--){
	string q; cin >> q;
	if(q[0] == 'L'){
	  if(q[1] == '-'){
		++sz; --l;
	  }
	  else{
		++l; --sz;
	  }
	}
	else{
	  if(q[1] == '-'){
		--sz;
	  }
	  else{
		++sz;
	  }
	}
	mem[sz].insert(l);
  }

  int ans = 0;
  for(auto isi: mem){
	sz = isi.first;
	set<pair<LL,LL>> s;
	for(int left: isi.second){
	  s.insert(rh.hash(left,left+sz));
	}
	ans += SZ(s);
  }

  cout << ans << endl;
  
  
  return 0;
}