def solve(mid,g):
    for t,d in zip(z[::2],z[1::2]):
        if s[mid]==t:
            mid-=(d<'R')or-1
    return mid==g
n,q,s,*z=open(0).read().split()
n,q=int(n),int(q)
s=' %s '%s
ok=0
ng=n+1
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if solve(mid,0):
        ok=mid
    else:
        ng=mid
a=ok
ok=n+1
ng=0
while abs(ok-ng)>1:
    mid=(ok+ng)//2
    if solve(mid,n+1):
        ok=mid
    else:
        ng=mid
print(max(0,ok-a-1))