n,q = map(int,input().split())
s = input()
t = [list(input().split()) for _ in range(q)]
dic = {}
for i in range(len(s)):
    if s[i] in dic:
        dic[s[i]].append(i)
    else:
        dic[s[i]] = [i]
ans = [1]*n
for t_ in t:
    if not t_[0] in dic:
        continue
    for i in dic[t_[0]]:
        if t_[1]=='R' and i<n-1:
            ans[i+1]+=ans[i]
        if t_[1]=='L' and i>0:
            ans[i-1]+=ans[i]
        ans[i] = 0
print(sum(ans))