n, q = map(int, input().split())
s    = input()
            
Q = []
for _ in range(q):
    Q.append(input().split())

s    = '$'+s+'$' 
         
def isRemove(pos, s, Q, target):
    cur  = pos        
            
    for t, d in Q:
        if cur == target:
            break
        
        if s[cur] != t:
            continue
            
        if d == 'L':
            cur -= 1
        else:
            cur += 1
            
    if cur == target:
        return True
    return False
          
l = 0
r = len(s) - 1
            
while r - l > 1:
    md = (r+l) // 2
    if isRemove(md, s, Q, 0):
        l = md
    else:
        r = md
            
mostRight = l
            
l = 0
r = len(s) - 1
            
while r - l > 1:
    md = (r+l) // 2
    if isRemove(md, s, Q, len(s)-1):
        r = md
    else:
        l = md        
            
mostLeft = r

print(mostLeft-mostRight-1) #AABCBDBA