#include <vector>
#include <string>
#include <iostream>
#include <utility>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

template <typename Container, typename HashType = ll, HashType mod1 = static_cast<HashType>(1000000007), HashType mod2 = static_cast<HashType>(1000000009), HashType add1 = static_cast<HashType>(1000010007), HashType add2 = static_cast<HashType>(1003333331)>
class RollingHash
{
public:
    static constexpr HashType MOD1 = mod1;
    static constexpr HashType MOD2 = mod2;
    using T = HashType;
    RollingHash(const Container& original) : size(original.size()), mt{random_device{}()}, base1{getRand1()}, base2{getRand2()}, pow1(size + 1, 1), pow2(size + 1, 1), accum_hash1(size + 1, 0), accum_hash2(size + 1, 0)
    {
        for (int i = 1; i <= size; i++) {
            pow1[i] = (pow1[i - 1] * base1) % mod1;
            accum_hash1[i] = (accum_hash1[i - 1] * base1 + add1 + static_cast<T>(original[i - 1])) % mod1;
        }
        for (int i = 1; i <= size; i++) {
            pow2[i] = (pow2[i - 1] * base2) % mod2;
            accum_hash2[i] = (accum_hash2[i - 1] * base2 + add2 + static_cast<T>(original[i - 1])) % mod2;
        }
    }
    RollingHash(const Container& original, const T base1, const T base2) : size(original.size()), mt{random_device{}()}, base1{base1}, base2{base2}, pow1(size + 1, 1), pow2(size + 1, 1), accum_hash1(size + 1, 0), accum_hash2(size + 1, 0)
    {
        for (int i = 1; i <= size; i++) {
            pow1[i] = (pow1[i - 1] * base1) % mod1;
            accum_hash1[i] = (accum_hash1[i - 1] * base1 + add1 + static_cast<T>(original[i - 1])) % mod1;
        }
        for (int i = 1; i <= size; i++) {
            pow2[i] = (pow2[i - 1] * base2) % mod2;
            accum_hash2[i] = (accum_hash2[i - 1] * base2 + add2 + static_cast<T>(original[i - 1])) % mod2;
        }
    }

    pair<T, T> getHash(const int l, const int r) const  // [l,r)
    {
        const T h1 = (((accum_hash1[r] - accum_hash1[l] * pow1[r - l]) % mod1) + mod1) % mod1;
        const T h2 = (((accum_hash2[r] - accum_hash2[l] * pow2[r - l]) % mod2) + mod2) % mod2;
        return make_pair(h1, h2);
    }

private:
    T getRand1()
    {
        static uniform_int_distribution<T> dist{2, mod1 - 1};
        return dist(mt);
    }
    T getRand2()
    {
        static uniform_int_distribution<T> dist{2, mod2 - 1};
        return dist(mt);
    }

    const int size;
    mt19937 mt;
    const T base1;
    const T base2;
    vector<T> pow1;
    vector<T> pow2;
    vector<T> accum_hash1;
    vector<T> accum_hash2;
};

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

    using P = pair<ll, ll>;
    vector<P> value;
    int l = 0;
    int r = 1;
    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 {
            r--;
        }
        value.push_back(hash.getHash(l, r));
    }
    sort(value.begin(), value.end());
    value.erase(unique(value.begin(), value.end()), value.end());
    cout << value.size() << endl;

    return 0;
}

Measured memory_bytes: 21128