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

class UnreliableRollingHash(ulong P) {
    // fast but unreliable rolling hash
    // base is P, modulus is 2^64
    ulong[] H;
    this(in string s) { 
        auto N = s.length;
        this.H = new ulong[](N + 1);
        foreach (int i, c; s) {
            H[i + 1] = (H[i] * P + cast(int)(c - 'a' + 1));
        }
    }
    ulong hash(int l, int r) { // [l, r)
        return H[r] - H[l] * pow(P, r - l);
    }
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;
    auto hasher = new UnreliableRollingHash!991(s);
    int l = 0, r = 1;
    bool[ulong] 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.length);
}