import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

n,q = inm()
s = input()
ddprint("n {} q {} s {}".format(n,q,s))
t = []
d = []
for i in range(q):
    tt,dd = input().split()
    t.append(tt)
    d.append(dd)
l = -1
r = n
for i in range(q-1,-1,-1):
    ddprint("i {} l {} r {}".format(i,l,r))
    if l < n-1 and t[i] == s[l+1] and d[i] == 'L':
        l += 1
    if l >= 0 and t[i] == s[l] and d[i] == 'R':
        l -= 1
    if r > 0 and t[i] == s[r-1] and d[i] == 'R':
        r -= 1
    if r < n and t[i] == s[r] and d[i] == 'L':
        r += 1
print(r-l-1)
