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

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

stones = [1 for k in range(n)]

for i in range(len(t)):
    tmp = -1
    if(d[i]=='L'):
        for j in range(s.count(t[i])):
            tmp = s.index(t[i], tmp + 1)
            if(tmp!=0):
                stones[tmp-1] += stones[tmp]
            stones[tmp] = 0
    else:
        for j in range(s.count(t[i])):
            tmp = sr.index(t[i], tmp + 1)
            if (tmp != 0):
                stones[n - tmp] += stones[n - 1 - tmp]
            stones[n - 1 - tmp] = 0

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

print(ans)