N, Q = map(int, input().split())
s = ['start']+ list(input()) + ['finish']
magic = [input().split() for i in range(Q)]

left = 0
leftmax = 0
right = N + 1
rightmin = N + 1

for mag in magic[::-1]:
    t = mag[0]
    d = mag[1]
    if d == 'L':
        if t == s[left + 1]:
            left += 1
        if right <= N:
            if  t == s[right + 1]:
                right += 1
    if d == 'R':
        if t == s[right - 1]:
            right -= 1
        if 1 <= left:
            if t == s[left - 1]:
                left -= 1
    leftmax = max(leftmax, left)
    rightmin = min(rightmin, right)
if leftmax - 1 >= rightmin:
    print(0)
else:
    print(rightmin - leftmax - 1)