N,Q = map(int,input().split())
s = input()
td = []
for i in range(Q):
    td.append(list(input().split()))

l = 0
r = N
while r-l>=1:
    middle = (l+r)//2
    index = middle
    for q in td:
        if index==-1 or index==N:
            break
        if q[0]==s[index]:
            if q[1]=='L':
                index -= 1
            else:
                index += 1
    if index==-1:
        l = middle+1
    else:
        r = middle
max_zero = r
l = 0
r = N
while r-l>=1:
    middle = (l+r)//2
    index = middle
    for q in td:
        if index==-1 or index==N:
            break
        if q[0]==s[index]:
            if q[1]=='L':
                index -= 1
            else:
                index += 1
    if index==N:
        r = middle
    else:
        l = middle+1
print(l-max_zero)