# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-
from sys import stdin

###########################################


############################################
#from sys import stdin
import numpy as np

# read data for n sequences.
d = stdin.readline().split()
N = int(d[0])
Q = int(d[1])
data = str(stdin.readline().split()[0])

q = []
for _ in range(Q):
    q.append(stdin.readline().split())

count=0
right=[]
left=[]
leftdict={}
rightdict={}
cache=[]

for i in data:
    if i not in cache:
        leftdict[i]=[]
        rightdict[i]=[]
        cache.append(i)
    
for i,d in enumerate(q):
    if d[0] in cache:
        if d[1]=='R':
            rightdict[d[0]].append(i)
        else:
            leftdict[d[0]].append(i)

def leftsearch(N, q, data):
    x = 0
    
    for spell in q:
        now = data[N]
        if now==spell[0]:
            if spell[1]=='R':
                N+=1
            else:
                N-=1
            if N==0:
                x = 1
                break
            elif N==len(data):
                break
    return(x)
def rightsearch(N, q, data):
    x = 0    
    for spell in q:
        now = data[N]
        if now==spell[0]:
            if spell[1]=='R':
                N+=1
            else:
                N-=1
            if N >= len(data):
                x = 1
                break
            elif N == 0:
                break
    return(x)

# binary search
left = 0
right = len(data)-1
while(right >= left):
    mid = left + (right - left)
    if 1 == leftsearch(mid, q, data):
        left = mid + 1
    else:
        right = mid -1
leftamount = mid

# right binary
left = 0
right = len(data)-1
while(right >= left):
    mid = left + (right - left)
    if 1 == rightsearch(mid, q, data):
        right = mid -1
    else:
        left = mid + 1
rightamount = len(data)-mid

print(len(data) - (leftamount + rightamount))
