import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,Q = IL()
s = S()
td = [SL() for i in range(Q)]
numA = 0
cnt = 1
for i in range(Q-1,-1,-1):
    if td[i]==[s[numA],"L"]:
        cnt -= 1
    elif numA == 0:
        continue
    elif td[i]==[s[numA-1],"R"]:
        cnt += 1
    
    if cnt == 0:
        numA += 1
        cnt = 1

numB = 0
cnt = 1
for i in range(Q-1,-1,-1):
    if td[i]==[s[N-1-numB],"R"]:
        cnt -= 1
    elif numB == 0:
        continue
    elif td[i]==[s[N-1-numB+1],"L"]:
        cnt += 1
    
    if cnt == 0:
        numB += 1
        cnt = 1

print(N - min(N,(numA + numB)))