import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
s = 'n' + input() + 'n'
mv = [input().split() for _ in range(Q)]

def move(ix):
    for i in range(Q):
        if mv[i][0]==s[ix]:
            if mv[i][1]=='L':
                ix -= 1
            else: ix += 1

            if ix == 0:
                return 'left'
            elif ix == N+1:
                return 'right'
    return 'safe'


if move(1) == 'right' or move(N) == 'left':
    print(0)
    exit()

if move(1) == 'left':
    lix = 1
    safemin = N
else:
    lix = 0
    safemin = 1
while safemin - lix > 1:
    t = (lix+safemin)//2
    if move(t) == 'left':
        lix = t
    else:
        safemin = t

if move(N) == 'right':
    rix = N
    safemax = 1
else:
    rix = N+1
    safemax = N
while - safemax + rix > 1:
    t = (safemax + rix)//2
    if move(t) == 'right':
        rix = t
    else:
        safemax = t
print(rix - lix - 1)