N, Q = map(int, input().split())
s = input()
td = [input().split() for _ in range(Q)]
alive = len(s)

for i in range(len(s)):
    idx = i
    char = s[idx]
    
    for td_ in td:
        
        if(td_[0] == char):
            
            if(td_[1] == 'L'):
                idx -= 1
                char = s[idx]
            
            else:
                idx += 1
                char = s[idx]
                
        if(idx == -1 or idx == len(s)):
            alive -= 1
            break

print(alive)