n,q = map(int, input().split())
s = input()
k = []
c = []
for i in s:
    k.append(i)
    c.append(1)

for i in range(q):
    t,d = input().split()
    if d == 'L':
        z = -1
    else:
        z = 1

    for i in range(n):
        r = c[i]
        if t == k[i]:
            if r != 0:
                c[i] = 0
            if z < 0:
                if i != 0:
                    c[i-1] += r
            else:
                if i != n-1:
                    c[i+1] += r

print(sum(c))
