import sys
input = sys.stdin.readline

def judge(x):
    now = x
    
    for ti, di in td:
        if s[now]==ti:
            if di=='R':
                now += 1
            else:
                now -= 1
        
        if now==-1:
            return True
    
    return False

def judge2(x):
    now = x
    
    for ti, di in td:
        if s[now]==ti:
            if di=='R':
                now += 1
            else:
                now -= 1
        
        if now==N:
            return True
    
    return False
    
N, Q = map(int, input().split())
s = input()
td = [tuple(input().split()) for _ in range(Q)]

l, r = 0, N-1
while l<=r:
    mid = (l+r)//2
    if judge(mid):
        l = mid+1
    else:
        r = mid-1
L = r

l, r = 0, N-1
while l<=r:
    mid = (l+r)//2
    if judge2(mid):
        r = mid-1
    else:
        l = mid+1
R = l

print(R-L-1)