n,q = map(int,input().split())
s = list(input())
p = [tuple(map(str,input().split())) for i in range(q)]

#s[x]が左へ抜けるか O(q)
def judge_left(x):
    for i in range(q):
        if p[i][0] == s[x]:
            if p[i][1] == 'L':
                x -= 1
            else:
                x += 1
        if x == -1:
            return True
        if x == n:
            return False
    return False

#s[x]が右へ抜けるか O(q)
def judge_right(x):
    for i in range(q):
        if p[i][0] == s[x]:
            if p[i][1] == 'L':
                x -= 1
            else:
                x += 1
        if x == -1:
            return False
        if x == n:
            return True
    return False

#どこまで左で抜けるか
ok = -1
ng = n
while ng-ok > 1:
    mid = (ng+ok)//2
    if judge_left(mid):
        ok = mid
    else:
        ng = mid
left = ok+1

#どこまで右で抜けるか
ok = n
ng = -1
while ok-ng >1:
    mid = (ok+ng)//2
    if judge_right(mid):
        ok = mid
    else:
        ng = mid
right = n-ok

print(max(n-left-right,0))