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

ss = list(s)
nn = []

m = {}
i = 0
for c in ss:
    i_str = str(i)
    if c in m:
        m[c][i_str] = True
    else:
        m[c] = {}
        m[c][i_str] = True
    i += 1
    nn.append(1)

for i in range(Q):
    t, d = map(str, input().split())
    if not t in m:
        continue
    for mi in m[t]:
        i_num = int(mi)
        if d == 'L':
            if 0 < i_num:
                nn[i_num - 1] += nn[i_num]
        else:
            if i_num < N - 1:
                nn[i_num + 1] += nn[i_num]
        nn[i_num] = 0 

print(sum(nn))
