import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

long pow(long x, long n, long M) {
    if (n == 0) return 1;
    if (n & 1) return x * pow(x, n - 1, M) % M;
    auto y = pow(x, n / 2, M);
    return y * y % M;
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;

    long[] MOD = [999999883, 1000000093, 1000000097];
    long B = 899999929;

    auto H = new long[3];
    auto T = new long[][](3, N + 1);
    foreach (h; 0 .. 3) {
        foreach (i; 0 .. N) {
            T[h][i + 1] = (T[h][i] * B + cast(long)(s[i])) % MOD[h];
        }
    }

    long[3] hash(size_t lb, size_t ub) {
        long[3] ret;
        foreach (i; 0 .. 3) {
            ret[i] = (MOD[i] + T[i][ub] - (B.pow(ub - lb, MOD[i]) * T[i][lb] % MOD[i])) % MOD[i];
        }
        return ret;
    }

    int L, R;
    bool[long[3]] set;
    foreach (m; 0 .. M) {
        auto q = readln.chomp;
        if (q[0] == 'L') {
            if (q[1] == '+') {
                L++;
            } else {
                L--;
            }
        } else { assert(q[0] == 'R');
            if (q[1] == '+') {
                R++;
            } else {
                R--;
            }
        }
        //writeln([L, R], hash(L, R + 1));
        set[hash(L, R + 1)] = true;
    }
    writeln(set.length);
}