import numpy as np
N,Q = map(int, input().split())
s = str(input())
t = []
d = []
for i in range (Q):
    tt,dt = map(str, input().split())
    t.append(tt)
    d.append(dt)


lr ={}
lr["L"]=-1
lr["R"]=1

hako = np.ones(N)

for i in range (Q):
    for j in range(N):
        if t[i] == s[j]:
            if j+lr[d[i]] >-1 and j+lr[d[i]]<N-1:
                hako[j+lr[d[i]]] += hako[j]
                hako[j] = 0
            else:
                hako[j] = 0
             
print(int(hako.sum()))
