N, Q = map(int, input().split())
s = input()
l = [1] * N
for i in range(Q):
    t, d = map(str, input().split())
    j = 0
    while j < N:
        j = s.find(t, j)
        if j < 0:
            break
        if d == "L":
            if j != 0:
                l[j-1] += l[j]
        else:
            if j != N-1:
                l[j+1] += l[j]
        l[j] = 0
        j += 1
print(sum(l))
