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_)

ans = [0 for i in range(n)]

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

        if ind-1>=0 and t[i]==s[ind-1]:
            if d[i]=='R':
                ind-=1
                ans[ind]=1
                
        if ind+1<=n-1 and t[i]==s[ind]:
            if d[i]=='L':
                ind+=1
                ans[ind]=1
                
        else:
            return 0
        
    return ind
        

li = tansaku_left(-1)

ri = tansaku_right(n)

print(n-(li+1)-(n-ri))


