N, Q = list(map(int, input().split()))
s = input()
G = []
l = {'A':[], 'B':[], 'C':[], 'D':[], 'E':[], 'F':[], 'G':[], 'H':[], 'I':[], 
    'J':[], 'K':[],'L':[], 'M':[], 'N':[], 'O':[], 'P':[], 'Q':[], 'R':[],
    'S':[], 'T':[], 'U':[], 'V':[], 'W':[], 'X':[], 'Y':[], 'Z':[]}
# 初期のゴーレムの配置
for i in range(N):
    G.append(1)
    l[s[i]].append(i) # その文字列が何番か

for i in range(Q):
    t, d = input().split()
    for m in l[t]:
        if m != 0 and d == 'L': # 端でなければ左どなりに
            G[m - 1] += G[m]
        elif m != N-1 and d == 'R':
            G[m + 1] += G[m]
        G[m] = 0 # 移動するのでその場から消す

print(sum(G))

