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