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

S = list(input())
S.insert(0,[''])
S.append([''])
G = [1]*N
G.insert(0,0)
G.append(0)
# |S| = N+2

for q in range(Q):

    t, d = input().split()

    if d == 'L':
        for idx, s in enumerate(S):
            if s == t:
                gn = G[idx]
                G[idx-1] += gn
                G[idx] -= gn

    elif d == 'R':
        for idx, s in enumerate(reversed(S)):
            if s == t:
                gn = G[-idx-1]
                G[-(idx-1)-1] += gn
                G[-idx-1] -= gn


    G[0] = 0
    G[-1] = 0
    #print(G)

res=0
for g in G:
    res += (g)

print(res)
