import std.algorithm;
import std.range;
import std.ascii;
import std.array;
import std.container;
import std.conv;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

long modPow(long mod)(long x, long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return modPow!mod(x * x % mod, n / 2);
    return x * modPow!mod(x % mod, n - 1) % mod;
}

class RollingHash(long[] Ps, long mod) {
    string s;
    int N;
    long[][] H;
    this(in string s) { 
        this.s = s; 
        this.N = s.size;
        this.H = new long[][](Ps.length, N + 1); // H[k]: s[0]*Ps[k]^(n-1) + s[1]*Ps[k]^(n-2) + ... + s[n-1]*Ps[k]^0
        foreach (k, P; Ps) {
            foreach (int i, c; s) {
                H[k][i + 1] = (H[k][i] * P + cast(int)(c - 'a' + 1)) % mod;
            }
        }
    }
    long[] hash(int l, int r) { // [l, r)
        auto hs = iota(0, Ps.length, 1).map!(delegate(k) {
                      return (H[k][r] - H[k][l] * modPow!mod(Ps[k], r - l) % mod + mod) % mod;
                  });
        return hs.array;
    }
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;
    auto hasher = new RollingHash!([991, 9999991], cast(long)(1e9+7))(s);
    int l = 0, r = 1;
    bool[long[]] appeared;
    foreach (_; 0 .. M) {
        auto q = readln.chomp;
        switch (q) {
            case "L++": l++; break;
            case "L--": l--; break;
            case "R++": r++; break;
            case "R--": r--; break;
            default: assert(false);
        }
        appeared[hasher.hash(l, r).idup] = true;
    }
    writeln(appeared.keys.size);
}