N, Q = list(map(int, input().split()))
s = input()
spells =  [input().split() for i in range(Q)]

def sim(pos, s, spells, N):
    for sp in spells:
        if s[pos] == sp[0]:
            pos += -1 if sp[1] == "L" else 1
            if pos < 0:
                return "LDead"
            if pos >= N:
                return "RDead"
    return "Alive"

#LD探し
Lpos = -1
Rpos = N
while Lpos+1<Rpos:
    pos = (Lpos+Rpos)//2
    if sim(pos, s, spells, N) == "LDead":
        Lpos = pos
    else:
        Rpos = pos
LDpos = Lpos ###LDeadの中で一番境界に近いもの

#RD探し
Lpos = -1
Rpos = N
while Lpos+1<Rpos:
    pos = (Lpos+Rpos)//2
    if sim(pos, s, spells, N) == "RDead":
        Rpos = pos
    else:
        Lpos = pos
RDpos = Rpos ###RDeadの中で一番境界に近いもの

print(max(0,RDpos-LDpos-1))