import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long BASE = 31;
immutable long MOD = 10^^9 + 9;
immutable long BASE_INV = powmod(BASE, MOD-2, MOD);

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto S = readln.chomp.map!(c => to!long(c - 'a') + 1).array;

    auto P = new long[](N+1);
    P[0] = 1;
    foreach (i; 0..N) P[i+1] = P[i] * BASE % MOD;

    auto D = new bool[long][](N+1);
    int l = 0;
    int r = 0;
    long ans = 0;
    long hash = S[0];

    while (M--) {
        auto Q = readln.chomp;
        if (Q == "L--") {
            l -= 1;
            hash = hash * BASE % MOD + S[l];
            hash %= MOD;
        } else if (Q == "L++") {
            hash = (hash - S[l]) % MOD;
            hash = hash * BASE_INV % MOD;
            hash = (hash + MOD) % MOD;
            l += 1;
        } else if (Q == "R--") {
            hash = (hash - S[r] * P[r - l] % MOD) % MOD;
            hash = (hash + MOD) % MOD;
            r -= 1;
        } else {
            r += 1;
            hash = (hash + S[r] * P[r - l] % MOD) % MOD;
            hash = (hash + MOD) % MOD;
        }
        if (hash !in D[r-l+1]) {
            D[r-l+1][hash] = true;
            ans += 1;
        }
    }

    ans.writeln;
}

long powmod(long a, long x, long m) {
    long ret = 1;
    while (x) {
        if (x % 2) ret = ret * a % m;
        a = a * a % m;
        x /= 2;
    }
    return ret;
}

