class spell:
    def __init__(self, text, dir):
        self.text = text
        self.dir = dir

def isRange(a):
    if(0 <= a < n):
        return True
    else:
        return False

n, q = map(int, input().split())
s = input()

spells = []
for i in range(q):
    text, dir = input().split()
    spells.append(spell(text, dir))


l = -1
r = n

for sp in reversed(spells):
    if(isRange(l+1) and s[l+1] == sp.text and sp.dir == 'L'):
        l += 1
    elif(isRange(l) and s[l] == sp.text and sp.dir == 'R'):
        l -= 1
    if(isRange(r-1) and s[r-1] == sp.text and sp.dir == 'R'):
        r -= 1
    elif(isRange(r) and s[r] == sp.text and sp.dir == 'L'):
        r += 1

print(n-(l+1)-(n-r))
