N, Q = map(int, input().split())
s = str(input())

t = []
d = []

for _ in range(Q):
    ti, di = map(str, input().split())
    t.append(ti)
    d.append(di)
    
def is_dead(i):
    LEFT_DIE = -1
    RIGHT_DIE = len(s)
    for ti, di in zip(t, d):
        if s[i] == ti:
            if di == 'L':
                i -= 1
            if di == 'R':
                i += 1
            if i == LEFT_DIE or i == RIGHT_DIE:
                return True
    return False

def check_left():
    tmp = -1
    for i in range(len(s)):
        if is_dead(i):
            tmp = i
        else:
            return tmp

def check_right():
    tmp = len(s)
    for i in range(len(s)):
        i = len(s) - i - 1
        if is_dead(i):
            tmp = i
        else:
            return tmp
        
        

left_edge = check_left()
#print(left_edge)
right_edge = check_right()
#print(right_edge)

ans_s = s[left_edge+1:right_edge]
#print(ans_s)
ans = len(ans_s)
print(ans)

        
        
        
        
        
        