import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
ss = input()
tds = [tuple(input().split()) for _ in range(Q)]

def isOK(pos):
    for t, d in tds:
        if t == ss[pos]:
            if d == 'L':
                pos -= 1
                if pos < 0:
                    return False
            else:
                pos += 1
                if pos > N-1:
                    return False
    return True

ng, ok = -1, N
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
L = ok

ng, ok = N, -1
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid
R = ok

print(R-L+1)
