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
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

class RollingHash{
private:
    ll base1, base2, mod1, mod2; // use two primes to prevent hash collision
    vector<ll> hash1, hash2, pow1, pow2, ipow1, ipow2;
    
    ll pow_mod(ll a, ll b, ll m){
        ll ret = 1;
        while (b > 0) {
            if (b & 1) {
                ret = ret * a % m;
            }
            a = a * a % m;
            b >>= 1;
        }
        return ret;
    }
    
    ll inv_mod(ll a, ll m){
        return pow_mod(a, m - 2, m);
    }
    
public:
    RollingHash(string s, ll mod1 = 1000000007, ll mod2 = 1000000009, ll base1 = 1009, ll base2 = 1007) : mod1(mod1), mod2(mod2), base1(base1), base2(base2), hash1(s.size() + 1), hash2(s.size() + 1), pow1(s.size() + 1), pow2(s.size() + 1), ipow1(s.size() + 1), ipow2(s.size() + 1) {
        pow1[0] = pow2[0] = 1;
        rep(i, s.size()){
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
            hash1[i + 1] = (hash1[i] + s[i]) * base1 % mod1;
            hash2[i + 1] = (hash2[i] + s[i]) * base2 % mod2;
        }
        rep(i, s.size() + 1){
            ipow1[i] = inv_mod(pow1[i], mod1);
            ipow2[i] = inv_mod(pow2[i], mod2);
        }
    }
    
    ll getHash(int l, int r){
        ll h1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
        return h1;
    }
    
    pair<ll, ll> getHashes(int l, int r){
        ll h1 = ((hash1[r] - hash1[l] * pow1[r - l]) % mod1 + mod1) % mod1;
        ll h2 = ((hash2[r] - hash2[l] * pow2[r - l]) % mod2 + mod2) % mod2;
        return mp(h1, h2);
    }
    
    
    
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, Q;
    string S;
    cin >> N >> Q >> S;
    RollingHash rh(S);
    
    vector<pair<ll, ll>> hashSet;
    int l = 0, r = 1;
    rep(i, Q){
        string q;
        cin >> q;
        if (q == "L++") l++;
        if (q == "L--") l--;
        if (q == "R++") r++;
        if (q == "R--") r--;
        hashSet.pb(rh.getHashes(l, r));
        // cout << S.substr(l, r - l) << endl;
        // cout << l << ", " << r << endl;
    }
    
    sort(all(hashSet));
    int ret = 1;
    repd(i, 1, hashSet.size()){
        if (hashSet[i] != hashSet[i - 1]) {
            ret++;
        }
    }
    
    output(ret, 0);
    
    
    return 0;
}