N, Q = map(int, input().split())
s = input()

golems = []
for n in range(N):
    golems.append(1)

for q in range(Q):
    t, d = input().split()
    after_magic = [0] * N

    for n in range(N):
        if s[n] == t:
            if d == 'L':
                if n != 0:
                    after_magic[n-1] += golems[n]
                else:
                    pass
            else: # R
                if n != N-1:
                    after_magic[n+1] += golems[n]
                else:
                    pass
        else:
            after_magic[n] += golems[n]

    golems = after_magic

print(sum(after_magic))
