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

ans = 0

l = 0
r = n
m = (l+r)//2
while r-l > 1:
    a = m
    for i in range(q):
        if T[i][0] == s[a]:
            if T[i][1] == "L":
                a -= 1
            else:
                a += 1
        if a < 0 or a >= n:
            break
    
    if a >= n:
        r = m
    else:
        l = m
    m = (l+r)//2

ans += n-l-1


l = -1
r = n-1
m = (l+r)//2
while r-l > 1:
    a = m
    for i in range(q):
        if T[i][0] == s[a]:
            if T[i][1] == "L":
                a -= 1
            else:
                a += 1
        if a < 0 or a >= n:
            break
    
    if a < 0:
        l = m
    else:
        r = m
    m = (l+r)//2

ans += r

print(n - ans)