def check(t,d,S,LR):
    start = 0
    end = len(S)-1
    while start!=end:
        index = (start+end)//2
        for i in range(len(t)):
            if len(t)-i<index-start and LR=="L":
                break
            if len(t)-i<end-index and LR=="R":
                break
            if S[index] == t[i]:
                if d[i]=="L":
                    index -= 1
                else:
                    index += 1
            if index<=0 or index>=len(S)-1:
                break
        if LR=="L":
            if index <= 0:
                start = (start+end)//2+1
            else:
                end = (start+end)//2
        else:
            if index >= len(S)-1:
                end = (start+end)//2
            else:
                start = (start+end)//2+1
    return start

N,Q = map(int,input().split())
S = "0" + input() + "0"
t = []
d = []
for i in range(Q):
    _ = input().split()
    t.append(_[0])
    d.append(_[1])
print(check(t,d,S,"R")-check(t,d,S,"L"))
