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)

#print(t, d)

g = [1 for i in range(n)]

for i in range(q):
    for j in range(n):
        if s[j] == t[i]:
    
            if d[i] == 'L':
                dx = -1
            if d[i] == 'R':
                dx = 1

            dn = g[j]
            g[j] -= dn
            if 0 <= j + dx < n:
                g[j + dx] += dn
    
print(sum(g))