#
import sys
import math
import numpy as np
import itertools

# いくつか入力
n,q = (int(i) for i in input().split())  
# 文字列をリストに
s = list(input())

# n行複数列の数をリストに
td = [[i for i in input().split()] for i in range(q)] 

#print(s,td)
answer = n
for i in range(n):
    temp = i
    for j in range(q):
        if td[j][0] == s[temp]:
            if td[j][1]== 'R':
                temp += 1
            else:
                temp -= 1
            if temp <0 or temp >= n:
                answer -= 1
#                print("l",i)
                break
#    print("a",temp)

print(answer)


