n, q = list(map(int,input().split()))
s = input()
l = [input().split() for i in range(q)] #A L とか
miti = [1]*(n+2) #ますにいるゴーレムの数
kazu = {} #dict型 keyのマスの場所
for i in range(len(s)) :
    kazu.setdefault(s[i],[]).append(i+1)
for i in l :
    miti1 = miti[:]
    for j in kazu[i[0]] :
        if i[1] == "L" :
            miti1[j-1] += miti[j]
            miti1[j] -= miti[j]
        else :
            miti1[j+1] += miti[j]
            miti1[j] -= miti[j]
    miti = miti1
    #print(miti)
print(sum(miti[1:-1]))
#print(miti)
#print(kazu)
