n, q = map(int, input().split())
s = input()
td = [input().split() for i in range(q)]
start = 0
now = "s"
use_s = "s" + s + "e"
for t, d in td[::-1]:
    if d == "L":
        if start >= n+1:
            continue
        if use_s[start+1] == t:
            start += 1
            now = t
    else:
        if start <= 0:
            continue
        if use_s[start-1] == t:
            if t == now:
                start -=1
ans = []
ans.append(start)

start = n+1
now = "e"
for t, d in td[::-1]:
    if d == "L":
        if start >= n+1:
            continue
        if use_s[start+1] == t:
            if t == now:
                start +=1
    else:
        if start <= 0:
            continue
        if use_s[start-1] == t:
            start -= 1
            now = t

ans.append(start)
if ans[0] >= ans[1]:
    print(0)
else:
    print(ans[1]-ans[0]-1)