import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

ll,lr=0,n+1
while lr-ll>1:
    mid=(lr+ll)//2
    for i in range(q):
        if mid==0:
            break
        t,d=td[i]
        if s[mid-1]==t:
            if d=="L":
                mid-=1
            else:
                mid+=1
    if mid==0:
        ll=(lr+ll)//2
    else:
        lr=(lr+ll)//2
# print(ll)

ikeru,ikenai=n+1,0
while ikeru-ikenai>1:
    mid=celi(ikeru+ikenai,2)
    for i in range(q):
        if mid==n+1:
            break
        t,d=td[i]
        if s[mid-1]==t:
            if d=="L":
                mid-=1
            else:
                mid+=1
    if mid==n+1:
        ikeru=celi(ikeru+ikenai,2)
    else:
        ikenai=celi(ikeru+ikenai,2)

# print(ikeru)
print(max(0,n-(ll+n+1-ikeru)))