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
bef = ''
judge = s[0]
for i in range(q-1,-1,-1):
    if p[i][0] == bef and p[i][1] == 'R':
        res -= 1
        break
    if p[i][0] == judge and p[i][1] == 'L':
        res += 1
        if res == n:
            break
        bef = judge
        judge = s[res]
res = max(0,res)

bef = ''
res2 = 0
judge = s[n-1]
for i in range(q-1,-1,-1):
    if p[i][0] == bef and p[i][1] == 'L':
        res2 -= 1
        break
    if p[i][0] == judge and p[i][1] == 'R':
        res2 += 1
        if res2 == n:
            break
        bef = judge
        judge = s[n-1-res2]
res2 = max(0,res2)
print(min(n,n-res-res2))