n,q = map(int,input().split())
s = list(input())
p = []
for i in range(q):
    t,d = map(str,input().split())
    p.append([t,d])

res = 0
cnt = 0
end = True
bef = ''
judge = s[0]
for i in range(q-1,-1,-1):
    if p[i][0] == bef and p[i][1] == 'R':
        end = False
        judge = bef
        cnt -= 1
        if cnt == -1:
            bef = ''
            cnt = 0
        else:
            bef = s[cnt]
    elif p[i][0] == judge and p[i][1] == 'L':
        res = max(cnt+1,res)
        if cnt+1>=res:
            end = True
        cnt += 1
        if res == n:
            break
        bef = judge
        judge = s[cnt]
if not end:
    res -= 1
res = max(0,res)

bef = ''
cnt = 0
end = True
res2 = 0
judge = s[n-1]
for i in range(q-1,-1,-1):
    if p[i][0] == bef and p[i][1] == 'L':
        end = False
        judge = bef
        cnt -= 1
        if cnt == -1:
            bef = ''
            cnt = 0
        else:
            bef = s[n-1-cnt]
    if p[i][0] == judge and p[i][1] == 'R':
        res2 = max(cnt+1,res2)
        if cnt+1 >= res2:
            end = True
        cnt += 1
        if res2 == n:
            break
        bef = judge
        judge = s[n-1-cnt]
if not end:
    res2 -= 1
res2 = max(0,res2)

print(min(n,n-res-res2))
