import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void main()
{
    long N, Q;
    scan(N, Q);
    auto S = sread();
    auto T = new char[](Q);
    auto D = new char[](Q);
    foreach (i; 0 .. Q)
        scan(T[i], D[i]);

    bool isSurviveLeft(long x)
    {
        long now = x;
        foreach (i; 0 .. Q)
            if (T[i] == S[now])
            {
                now += (D[i] == 'R') ? 1 : -1;
                if (now == -1)
                    return false;
                if (now == N)
                    return true;
            }
        return true;
    }

    bool isSurviveRight(long x)
    {
        long now = x;
        foreach (i; 0 .. Q)
            if (T[i] == S[now])
            {
                now += (D[i] == 'R') ? 1 : -1;
                if (now == -1)
                    return true;
                if (now == N)
                    return false;
            }
        return true;
    }

    long l = () {
        long ok = N;
        long ng = -1;
        while (1 < abs(ok - ng))
        {
            long m = (ok + ng) / 2;
            if (isSurviveLeft(m))
            {
                ok = m;
            }
            else
            {
                ng = m;
            }
        }
        return ok;
    }();
    long r = () {
        long ok = -1;
        long ng = N;
        while (1 < abs(ok - ng))
        {
            long m = (ok + ng) / 2;
            if (isSurviveRight(m))
            {
                ok = m;
            }
            else
            {
                ng = m;
            }
        }
        return ok;
    }();
    // iota(N).map!isSurviveLeft().writeln();
    // iota(N).map!isSurviveRight().writeln();
    // writeln(l);
    // writeln(r);
    writeln(r - l + 1);
}
