// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) begin(V), end(V)
#define ALLR(V) rbegin(V), rend(V)
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;

#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

struct RollingHash {
    constexpr static size_t RSIZE = 2;
    ll base_v[RSIZE] = { 1007, 1009, };
    ll mod_v[RSIZE] = { 167772161, 469762049, };
    V<ll> rpow[RSIZE], hash[RSIZE];

    ll mod_pow(ll n, ll k, ll m) { return k ? (k & 1 ? n : 1) * mod_pow(n * n % m, k / 2, m) % m : 1; }

    RollingHash(const string &s) {
        for (int i = 0; i < RSIZE; i++) {
            ll b = base_v[i], mod = mod_v[i];
            rpow[i].resize(s.size() + 1);
            hash[i].resize(s.size() + 1);
            rpow[i][0] = mod_pow(b, mod - 1 - s.size(), mod);
            for (int j = 0; j < s.size(); j++) rpow[i][j + 1] = rpow[i][j] * b % mod;
            reverse(ALL(rpow[i]));
            ll bm = 1;
            for (int j = 0; j < s.size(); j++) {
                ll n = s[j] - 'a' + 1;
                hash[i][j + 1] = hash[i][j] + bm * n;
                hash[i][j + 1] %= mod;
                bm = bm * b % mod;
            }
        }
    }

    PLL get_substr(ll l, ll r) {
        ll ret[RSIZE];
        for (int i = 0; i < RSIZE; i++) {
            ll rs = hash[i][r], ls = hash[i][l], mod = mod_v[i];
            ll h = rs + mod - ls;
            h %= mod;
            h *= rpow[i][l];
            h %= mod;
            ret[i] = h;
        }
        return make_pair(ret[0], ret[1]);
    }
};

int main() {
    ll n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    set<PLL> hash_s;
    RollingHash rh(s);
    ll l = 0, r = 1;
    while (m--) {
        string q;
        cin >> q;
        if (q == "L--") l--;
        else if (q == "L++") l++;
        else if (q == "R--") r--;
        else if (q == "R++") r++;
        hash_s.insert(rh.get_substr(l, r));
    }

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



Measured memory_bytes: 31212