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

ts,ds = [None]*Q, [None]*Q
for i in range(Q):
    ts[-i-1], ds[-i-1] = input().split()

l_pos = -1
l_pos_max = -1
for t, d in zip(ts,ds):
    if d == 'L':
        if s[l_pos+1] == t:
            l_pos+=1
    elif l_pos > 0:
        if s[l_pos-1] == t:
            l_pos-=1
    l_pos_max = max(l_pos_max, l_pos)

r_pos = N
r_pos_min = N
for t, d in zip(ts,ds):
    if d == 'R':
        if s[r_pos-1] == t:
            r_pos-=1
    elif r_pos < N-1:
        if s[r_pos+1] == t:
            r_pos+=1
    r_pos_min = min(r_pos_min, r_pos)

print(N - (l_pos_max+1) - (N - r_pos_min))

