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

def judge(k):#0:false 1:L 2:R
    pos = k
    posc = s[k]

    for i in range(q):
        if(t[i] != posc):continue
        if(d[i] == 'L'):
            pos -= 1
        else:
            pos += 1
        if pos == -1:
            return 1
        if pos == n:
            return 2
        posc = s[pos]

if(judge(0) != 1):ansl = 0
else:
    ll,rr = 0,n
    for i in range(100):
        if(rr -ll == 1): break
        
        md = (ll+rr) // 2

        if(judge(md) != 1) : rr = md
        else : ll = md
    ansl = ll+1

if(judge(n-1) != 2):ansr = 0
else:
    ll,rr = -1,n-1
    for i in range(100):
        if(rr -ll == 1): break
        
        md = (ll+rr) // 2

        if(judge(md) != 2) : ll = md
        else : rr = md
    ansr = n-rr

print(n-ansl-ansr)