import numpy as np
N, Q  = [int(a) for a in input().split()]
s = input()
s_dict = {c:[] for c in set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')}
s_m_dict = {c:[] for c in set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')}
s_p_dict = {c:[] for c in set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')}

for i, c in enumerate(s):
    s_dict[c].append(i+1)
    s_m_dict[c].append(i)
    s_p_dict[c].append(i+2)
g = np.ones(N+2, dtype=int)

for _ in range(Q):
    row = input()
    c, lr = row.split()
    mover = g[s_dict[c]]
    g[s_dict[c]] -= mover
    if lr == 'L':
        g[s_m_dict[c]] += mover
    else:
        g[s_p_dict[c]] += mover
    g[0] = 0
    g[-1] = 0

print(sum(g[1:-1]))