#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n,q=map(int,input().split())
s=input()
td=[]
for i in range(q):
    td.append(input().split())

#左に集まる中でもっとも右の点を探す
ok1=-1
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==-1:
            break
    if tmp==-1:
        left=mid+1
        ok1=max(ok1,mid)
    else:
        right=mid

#右に集まる中でもっとも左の点を探す

ok2=n
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==n:break
    if tmp == n:
        right=mid
        ok2=min(ok2,mid)
    else:
        left=mid+1

print(max(0,ok2-ok1-1))
# print(ok2,ok1)
