N, Q = list(map(int, input().split()))
s = input()
board = [1]*N
ss = {}
for idx, key in enumerate(s):
    if key in ss:
        ss[key].append(idx)
    else:
        ss[key] = [idx]
for i in range(Q):
    t, d = input().split()
    if not t in ss:
        continue
    for b_i in ss[t]:
        if d == 'L':
            if b_i == 0:
                board[b_i] = 0
            else:
                board[b_i-1] += board[b_i]
                board[b_i] = 0
        else:
            if b_i == N-1:
                board[b_i] = 0
            else:
                board[b_i+1] += board[b_i]
                board[b_i] = 0
print(sum(board))
