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

cell = [1 for _ in range(N)]
cell_type = {}
for idx, c in enumerate(s):
    if c in cell_type:
        cell_type[c].append(idx)
    else:
        cell_type[c] = [idx]

for _ in range(Q):
    t, d = input().split()
    if t not in cell_type:
        continue
    if d == 'L':
        for i in range(len(cell_type[t])):
            c = cell_type[t][i]
            if c != 0:
                cell[c-1] += cell[c]
            cell[c] = 0
    else:
        for i in range(len(cell_type[t])-1, -1, -1):
            c = cell_type[t][i]
            if c != N - 1:
                cell[c+1] += cell[c]
            cell[c] = 0

ans = 0
for c in cell:
    ans += c
print(ans)
