n,q = map(int,input().split())
s = input()
orders = list()
for i in range(q):
    orders.append(input().split())
    
s = "*"+s+"*"
left = 0
#間違えた
right = n+1

#左端を探す
while abs(left-right) > 1:
    m= (left+right)//2
    x = (left+right)//2
    
    for t,d in orders:
        if s[m] != t:
            continue
            
        if d == "R":
            m +=1
            
        if d == "L":
            m -= 1
            
        if m == 0:
            left = x
            break
    else:
        right = x
        
left_ans = left

left = 0
right = n + 1

#右端を探す
while abs(left-right) > 1:
    m = (left+right)//2
    x = (left+right)//2
    
    for t,d in orders:
        if s[m] != t:
            continue
            
        if d == "R":
            m +=1
            
        if d == "L":
            m -= 1
            
        if m == n+1:
            right = x
            break
    else:
        left = x
        
right_ans = right

# print(n - min(n, left_ans + (n + 1 - right_ans)))
print(n-(left_ans + n+1-right_ans))