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

t = ["a"]*Q
d = ["b"]*Q
for i in range(Q):
	t[i],d[i] = input().split()
	
a = [0]*26
a_max = [0]*26
a_min = [0]*26
for i in range(Q):
	if t[i] == "A" and d[i] == "R":
		a[0] += 1
	if t[i] == "A" and d[i] == "L":
		a[0] -= 1
	if t[i] == "B" and d[i] == "R":
		a[1] += 1
	if t[i] == "B" and d[i] == "L":
		a[1] -= 1
	if t[i] == "C" and d[i] == "R":
		a[2] += 1
	if t[i] == "C" and d[i] == "L":
		a[2] -= 1
	if t[i] == "D" and d[i] == "R":
		a[3] += 1
	if t[i] == "D" and d[i] == "L":
		a[3] -= 1
	if t[i] == "E" and d[i] == "R":
		a[4] += 1
	if t[i] == "E" and d[i] == "L":
		a[4] -= 1
	if t[i] == "F" and d[i] == "R":
		a[5] += 1
	if t[i] == "F" and d[i] == "L":
		a[5] -= 1
	if t[i] == "G" and d[i] == "R":
		a[6] += 1
	if t[i] == "G" and d[i] == "L":
		a[6] -= 1
	if t[i] == "H" and d[i] == "R":
		a[7] += 1
	if t[i] == "H" and d[i] == "L":
		a[7] -= 1
	if t[i] == "I" and d[i] == "R":
		a[8] += 1
	if t[i] == "I" and d[i] == "L":
		a[8] -= 1
	if t[i] == "J" and d[i] == "R":
		a[9] += 1
	if t[i] == "J" and d[i] == "L":
		a[9] -= 1
	if t[i] == "K" and d[i] == "R":
		a[10] += 1
	if t[i] == "K" and d[i] == "L":
		a[10] -= 1
	if t[i] == "L" and d[i] == "R":
		a[11] += 1
	if t[i] == "L" and d[i] == "L":
		a[11] -= 1
	if t[i] == "M" and d[i] == "R":
		a[12] += 1
	if t[i] == "M" and d[i] == "L":
		a[12] -= 1
	if t[i] == "N" and d[i] == "R":
		a[13] += 1
	if t[i] == "N" and d[i] == "L":
		a[13] -= 1
	if t[i] == "O" and d[i] == "R":
		a[14] += 1
	if t[i] == "O" and d[i] == "L":
		a[14] -= 1
	if t[i] == "P" and d[i] == "R":
		a[15] += 1
	if t[i] == "P" and d[i] == "L":
		a[15] -= 1
	if t[i] == "Q" and d[i] == "R":
		a[16] += 1
	if t[i] == "Q" and d[i] == "L":
		a[16] -= 1
	if t[i] == "R" and d[i] == "R":
		a[17] += 1
	if t[i] == "R" and d[i] == "L":
		a[17] -= 1
	if t[i] == "S" and d[i] == "R":
		a[18] += 1
	if t[i] == "S" and d[i] == "L":
		a[18] -= 1
	if t[i] == "T" and d[i] == "R":
		a[19] += 1
	if t[i] == "T" and d[i] == "L":
		a[19] -= 1
	if t[i] == "U" and d[i] == "R":
		a[20] += 1
	if t[i] == "U" and d[i] == "L":
		a[20] -= 1
	if t[i] == "V" and d[i] == "R":
		a[21] += 1
	if t[i] == "V" and d[i] == "L":
		a[21] -= 1
	if t[i] == "W" and d[i] == "R":
		a[22] += 1
	if t[i] == "W" and d[i] == "L":
		a[22] -= 1
	if t[i] == "X" and d[i] == "R":
		a[23] += 1
	if t[i] == "X" and d[i] == "L":
		a[23] -= 1
	if t[i] == "Y" and d[i] == "R":
		a[24] += 1
	if t[i] == "Y" and d[i] == "L":
		a[24] -= 1
	if t[i] == "Z" and d[i] == "R":
		a[25] += 1
	if t[i] == "Z" and d[i] == "L":
		a[25] -= 1
	for j in range(26):
		hoge1 = a_max[j]
		hoge2 = a[j]
		a_max[j] = max(hoge1,hoge2)
		hoge1 = a_min[j]
		a_min[j] = min(hoge1,hoge2)
ans = N
for i in range(N):
	if s[i] == "A":
		if (i+a_max[0]) >= N or (i+a_min[0]) <0:
			 ans -= 1
	if s[i] == "B":
		if (i+a_max[1]) >= N or (i+a_min[1]) <0:
			 ans -= 1
	if s[i] == "C":
		if (i+a_max[2]) >= N or (i+a_min[2]) <0:
			 ans -= 1
	if s[i] == "D":
		if (i+a_max[3]) >= N or (i+a_min[3]) <0:
			 ans -= 1
	if s[i] == "E":
		if (i+a_max[4]) >= N or (i+a_min[4]) <0:
			 ans -= 1
	if s[i] == "F":
		if (i+a_max[5]) >= N or (i+a_min[5]) <0:
			 ans -= 1
	if s[i] == "G":
		if (i+a_max[6]) >= N or (i+a_min[6]) <0:
			 ans -= 1
	if s[i] == "H":
		if (i+a_max[7]) >= N or (i+a_min[7]) <0:
			 ans -= 1
	if s[i] == "I":
		if (i+a_max[8]) >= N or (i+a_min[8]) <0:
			 ans -= 1
	if s[i] == "J":
		if (i+a_max[9]) >= N or (i+a_min[9]) <0:
			 ans -= 1
	if s[i] == "K":
		if (i+a_max[10]) >= N or (i+a_min[10]) <0:
			 ans -= 1
	if s[i] == "L":
		if (i+a_max[11]) >= N or (i+a_min[11]) <0:
			 ans -= 1
	if s[i] == "M":
		if (i+a_max[12]) >= N or (i+a_min[12]) <0:
			 ans -= 1
	if s[i] == "N":
		if (i+a_max[13]) >= N or (i+a_min[13]) <0:
			 ans -= 1
	if s[i] == "O":
		if (i+a_max[14]) >= N or (i+a_min[14]) <0:
			 ans -= 1
	if s[i] == "P":
		if (i+a_max[15]) >= N or (i+a_min[15]) <0:
			 ans -= 1
	if s[i] == "Q":
		if (i+a_max[16]) >= N or (i+a_min[16]) <0:
			 ans -= 1
	if s[i] == "R":
		if (i+a_max[17]) >= N or (i+a_min[17]) <0:
			 ans -= 1
	if s[i] == "S":
		if (i+a_max[18]) >= N or (i+a_min[18]) <0:
			 ans -= 1
	if s[i] == "T":
		if (i+a_max[19]) >= N or (i+a_min[19]) <0:
			 ans -= 1
	if s[i] == "U":
		if (i+a_max[20]) >= N or (i+a_min[20]) <0:
			 ans -= 1
	if s[i] == "V":
		if (i+a_max[21]) >= N or (i+a_min[21]) <0:
			 ans -= 1
	if s[i] == "W":
		if (i+a_max[22]) >= N or (i+a_min[22]) <0:
			 ans -= 1
	if s[i] == "X":
		if (i+a_max[23]) >= N or (i+a_min[23]) <0:
			 ans -= 1
	if s[i] == "Y":
		if (i+a_max[24]) >= N or (i+a_min[24]) <0:
			 ans -= 1
	if s[i] == "Z":
		if (i+a_max[25]) >= N or (i+a_min[25]) <0:
			 ans -= 1

print(ans)

