N, Q = map(int, input().split())
s = input()
T = []
D = []
for _ in range(Q):
	t, d = input().split()
	T.append(t)
	D.append(d)

# a_c = [0]*26
# a_max = [-10**6]*26
# a_min = [10**6]*26
# dict = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4, 'f':5, 'g':6, 'h':7,
#         'i':8, 'j':9, 'k':10, 'l':11, 'm':12, 'n':13, 'o':14,
#         'p':15, 'q':16, 'r':17, 's':18, 't':19, 'u':20, 'v':21,
#         'w':22, 'x':23, 'y':24, 'z':25}

ans = 0
left = ""
right = ""
# print(T,D)
for i in range(Q-1,-1,-1):
	# print(D[i])
	if D[i] == 'R':
		if T[i]+right == s[-1*len(T[i]+right):]:
			# print(T[i]+right)
			ans += 1
			right = T[i]+right
	else:
		if left+T[i] == s[:len(left+T[i])]:
			# print(left+T[i])
			ans += 1
			left = left+T[i]
print(N-ans)
