import std.algorithm;
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;
}

long extgcd(long a, long b, ref long x, ref long y) {
    long g = a; x = 1; y = 0;
    if (b != 0) {
        g = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }
    return g;
}
long inverse(long mod)(long v) {
    long x, y;
    if (extgcd(v, mod, x, y) == 1) return (x + mod) % mod;
    return 0;
}

class RollingHash(long X, long mod) {
    string s;
    int N;
    long[] H;
    this(in string s) { 
        this.s = s; 
        this.N = s.size;
        this.H = new long[N + 1];
        long x = 1;
        foreach (int i, c; s) {
            H[i + 1] = (H[i] + x * cast(int)(c - 'a' + 1)) % mod;
            x = (x * X) % mod;
        }
    }
    long hash(int l, int r) { // [l, r)
        long h = (H[r] - H[l] + mod) % mod;
        return h * modPow!mod(inverse!mod(X), l) % mod;
    }
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;
    auto hasher = new RollingHash!(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)] = true;
    }
    writeln(appeared.keys.size);
}