n, q = map(int, input().split())
s = input()
Q = [0] * q

for i in range(q):
    Q[i] = list(input().split())

left, right = 0, n-1
while left < right :
    half = int((left+right)/2)
    
    out = False
    
    idx = half
    for i in range(q):
        t = s[idx]
        
        if t == Q[i][0]:
            if Q[i][1] == "L":
                idx -= 1
            else:
                idx += 1
                
        if idx < 0:
            out = True
            break
        if idx > n-1:
            break
    
    if out:
        left = half+1
    else:
        right = half-1
        
leftans = min(left, right)+1

left, right = 0, n-1
while left < right:
    half = int((left+right)/2)
    
    out = False
    
    idx = half
    for i in range(q):
        t = s[idx]
        
        if t == Q[i][0]:
            if Q[i][1] == "L":
                idx-= 1
            else:
                idx += 1
                
        if idx > n-1:
            out = True
            break
        if idx < 0:
            break
        
    if out:
        right = half-1
    else:
        left = half+1
     
rightans = n - (min(left, right)+1)
print(n-(leftans+rightans))