n,q = list(map(int,input().split()))
s = str(input())

t =[]
d = []
for i in range(q):
    t_,d_ = list(map(str,input().split()))
    t.append(t_)
    d.append(d_)

# if you can go backwards, put 1
ans = [0 for i in range(n)]


def tansaku(ind):
    for i in range(q-1,-1,-1):
        if ind+1<=n-1 and t[i]==s[ind+1] and d[i]=='L':
            ind+=1
            ans[ind]=1
        if ind-1>=0 and t[i]==s[ind-1] and d[i]=='R':
            ind-=1
            ans[ind]=1

tansaku(-1)
tansaku(n)

print(n-sum(ans))