#include <bits/stdc++.h>
#define int long long
using namespace std;

struct RollingHash {
    using value_t = long long;
    template<value_t M, value_t B>
    struct RollingHashImpl {
    private:
        static constexpr value_t bpow(value_t a, value_t b) {
            value_t ret = 1;
            while (b > 0) {
                if (b & 1) ret = (ret * a) % M;
                a = (a * a) % M;
                b >>= 1;
            }
            return ret;
        }
        static constexpr value_t mod_inv(value_t a) {
            return bpow(a, M - 2);
        }
        static constexpr value_t invB = RollingHashImpl::mod_inv(B);
        
    public:
        deque<value_t> table, pow_b, pow_i;
        int len;
        
        RollingHashImpl(const string &str) {
            len = str.size();
            table.resize(len);
            pow_b.resize(len);
            pow_i.resize(len);
            for (int i = 0; i < len; i++) {
                if (i == 0) {
                    table[i] = str[i] % M;
                    pow_b[i] = 1;
                    pow_i[i] = 1;
                } else {
                    pow_b[i] = pow_b[i - 1] * B % M;
                    pow_i[i] = pow_i[i - 1] * invB % M;
                    table[i] = (table[i - 1] + pow_b[i] * str[i] % M) % M;
                }
            }
        }

        // [l, r)
        value_t substr(int l, int r) const {
            if (l == 0) return table[r - 1];
            return (table[r - 1] - table[l - 1] + M) % M * pow_i[l] % M;
        }

        RollingHashImpl &operator+=(const RollingHashImpl &r) {
            assert(this != &r);
            value_t back = (table.empty() ? 0 : table.back());
            table.insert(table.end(), r.table.begin(), r.table.end());
            pow_b.resize(len + r.len);
            pow_i.resize(len + r.len);
            value_t p = bpow(B, len);
            for (int i = len; i < len + r.len; i++) {
                table[i] = (back + table[i] * p % M) % M;
                pow_b[i] = (i > 0 ? pow_b[i - 1] * B % M : 1);
                pow_i[i] = (i > 0 ? pow_i[i - 1] * invB % M : 1);
            }
            len += r.len;
            return *this;
        }

        bool operator==(const RollingHashImpl &r) const {
            return table[len] == r.table[r.len] && len == r.len;
        }

        RollingHashImpl &operator=(const RollingHashImpl &r) = default;

        // O(1)
        void push_back(char c) {
            if (len + 1 > pow_b.size()) {
                value_t last_b = pow_b.empty() ? 1 : pow_b.back();
                pow_b.push_back(last_b * B % M);
                value_t last_i = pow_i.empty() ? 1 : pow_i.back();
                pow_i.push_back(last_i * invB % M);
            }
            table.push_back((table.back() + pow_b[len] * c % M) % M);
            len++;
        }
        // O(1)
        void pop_back() {
            len--;
        }

        // O(len)
        void push_front(char c) {
            for (auto &x : table) {
                x = x * B % M;
            }
            table.push_front(c % M);
            len++;
        }
        // O(len)
        void pop_front() {
            table.pop_front();
            for (auto &x : table) {
                x = x * invB % M;
            }
            len--;
        }
    };

    RollingHashImpl<1970156953LL, 8243147LL> hash1;
    RollingHashImpl<1863766631LL, 8630737LL> hash2;
    RollingHashImpl<1504655027LL, 2660047LL> hash3;
    using hash_t = tuple<value_t, value_t, value_t>;
    
    RollingHash(const string &str) : hash1(str), hash2(str), hash3(str) {}

    // [l, r)
    hash_t substr(int l, int r) const {
        return make_tuple(hash1.substr(l, r), hash2.substr(l, r), hash3.substr(l, r));
    }
    hash_t hash() const {
        assert(hash1.len == hash2.len and hash2.len == hash3.len);
        return substr(0, hash1.len);
    }
    
    void append(const RollingHash &r) {
        hash1 += r.hash1;
        hash2 += r.hash2;
        hash3 += r.hash3;
    }
    RollingHash &operator+=(const RollingHash &r) {
        append(r);
        return *this;
    }

    bool operator==(const RollingHash &r) const {
        return hash1 == r.hash1 && hash2 == r.hash2 && hash3 == r.hash3;
    }
    bool operator!=(const RollingHash &r) const { return !(*this == r); }

    void push_back(char c) {
        hash1.push_back(c);
        hash2.push_back(c);
        hash3.push_back(c);
    }
    void pop_back() {
        hash1.pop_back();
        hash2.pop_back();
        hash3.pop_back();
    }
    void push_front(char c) {
        hash1.push_front(c);
        hash2.push_front(c);
        hash3.push_front(c);
    }
    void pop_front() {
        hash1.pop_front();
        hash2.pop_front();
        hash3.pop_front();
    }
};

signed main() {
    int n, m;
    string s;
    cin >> n >> m >> s;
    RollingHash hash(s);

    set<RollingHash::hash_t> substrs;

    int l = 0, r = 0;
    for (int i = 0; i < m; i++) {
        string q;
        cin >> q;
        if (q == "L++") {
            l++;
        } else if (q == "L--") {
            l--;
        } else if (q == "R++") {
            r++;
        } else if (q == "R--") {
            r--;
        }
        substrs.insert(hash.substr(l, r + 1));
    }
    cout << substrs.size() << endl;
    return 0;
}


Measured memory_bytes: 44048