import numpy as np

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

ads = np.array([[0]*(N+4) for i in range(26)])
for i in range(N):
    p = ord(S[i])-65
    ads[p][i+2] = 1

golems = np.array([0]+[1]*(N)+[0])

for i in range(Q):
    td = input()
    idxes = ads[ord(td[0])-65]
    idou = idxes[2:-2]*golems[1:-1]
    golems[1:-1] -= idou
    if td[-1]=='L':
        golems[:-2] += idou
    else:
        golems[2:] += idou

print(golems[1:-1].sum())