N, Q = map(int, input().split())
ss = '#' + input() + '#'
tds = [tuple(input().split()) for _ in range(Q)]

# 左端
iL = 0
for t, d in reversed(tds):
    if t == ss[iL] and d == 'R':
        iL -= 1
    if t == ss[iL+1] and d == 'L':
        iL += 1
    if iL == N:
        break

# 右端
iR = N+1
for t, d in reversed(tds):
    if t == ss[iR] and d == 'L':
        iR += 1
    if t == ss[iR-1] and d == 'R':
        iR -= 1
    if iR == 1:
        break

ans = N - min(N, iL+N+1-iR)
print(ans)
