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

def check(x, target) :
    for t, d in td :
        if s[x] == t :
            if d == 'L' :
                x -= 1
            else :
                x += 1
        
        if x == target :
            return True
            
    return False

ret = 0
ok, ng = 0, N + 1
while ng - ok > 1 :
    mid = (ok + ng) // 2
    if check(mid, 0) :
        ok = mid
    else :
        ng = mid

ret += ok

ng, ok = 0, N + 1
while ok - ng > 1 :
    mid = (ok + ng) // 2
    if check(mid, N + 1) :
        ok = mid
    else :
        ng = mid
        
ret += N + 1 - ok

print(N - min(ret, N))