N, Q = list(map(int, input().split()))
s = input()
golem = [1] * N
for _ in range(Q):
    t, d = input().split()
    if d == 'L':
        for i, c in enumerate(s):
            if c == t:
                if i > 0:
                    golem[i-1] += golem[i]
                    golem[i] = 0
                else:
                    golem[i] = 0
    else:
        for i, c in enumerate(s):
            if c == t:
                if i < N-1:
                    golem[i+1] += golem[i]
                    golem[i] = 0
                else:
                    golem[i] = 0
print(sum(golem))
