N,Q = map(int, input().split())
S = input()
TD = [ input().split() for _ in range(Q)]


N = len(S)
ans = 0

# N-1 falls from right edge ? 
nowpos = N-1
fall_f = False
for i in range(Q):
    t,d = TD[i]
    nowChar = S[nowpos]
    if t == nowChar:
        if d == "L":
            nowpos -= 1
            if nowpos == -1:
                break
        if d == "R":
            nowpos += 1
            if nowpos == N:
                fall_f = True
                break

if fall_f:
    ok = N-1
    ng = 0
    mid = (ok+ng)//2
    while abs(ok - ng) > 1:
        nowpos = mid
        fall_f = False

        for i in range(Q):
            t,d = TD[i]
            nowChar = S[nowpos]
            if t == nowChar:
                if d == "L":
                    nowpos -= 1
                    if nowpos == -1: break
                if d == "R":
                    nowpos += 1
                    if nowpos == N:
                        fall_f = True
                        break
        if fall_f :
            ok = mid
        else:
            ng = mid

        mid = (ok+ng)//2

    ans += N - ok 

    

    
# 0 fallse from left edge  ?
nowpos = 0
fall_f = False
for i in range(Q):
    t,d = TD[i]
    nowChar = S[nowpos]
    if t == nowChar:
        if d == "L":
            nowpos -= 1
            if nowpos == -1:
                fall_f = True
                break
        if d == "R":
            nowpos += 1
            if nowpos == N:
                break
if fall_f:

    ok = 0
    ng = N-1
    mid = (ok+ng)//2
    while abs(ok - ng) > 1:

        nowpos = mid
        fall_f = False

        for i in range(Q):
            t,d = TD[i]
            nowChar = S[nowpos]
            if t == nowChar:
                if d == "L":
                    nowpos -= 1
                    if nowpos == -1: 
                        fall_f = True
                        break
                if d == "R":
                    nowpos += 1
                    if nowpos == N:
                        # fall_f = True
                        break
        if fall_f :
            ok = mid
        else:
            ng = mid

        mid = (ok+ng)//2

    ans +=  ok + 1

print(N - ans)

