import numpy as np
if __name__ == '__main__':
	N,Q = map(int, input().split())
	s = input()
	char_dict = {}
	nums = np.ones(N+2)
	nums[0] = 0
	nums[N+1] = 0
	for i in range(N):
		if(s[i] in char_dict.keys()):
			val = char_dict[s[i]]
			char_dict[s[i]] = np.append(val,[i])
		else :
			char_dict[s[i]] = np.array([i])

	for _ in range(Q):
		t,d = input().split()
		if( t in char_dict.keys()):
			if(d=='L'):
				nums[char_dict[t]] += nums[char_dict[t]+1]
				nums[char_dict[t]+1]=0
			else:
				nums[char_dict[t]+2] += nums[char_dict[t]+1]
				nums[char_dict[t]+1]=0
	print(char_dict)
	print(int(N - nums[0] - nums[N+1]))