require 'set'

n, q = gets.split.map(&:to_i)

L = 0
R = 0

S = gets

s = Set.new

for i in 1..q do
	
	query = gets

	if query == "L++\n" then
		L += 1
	end
	
	if query == "L--\n" then
		L -= 1
	end
	
	if query == "R++\n" then
		R += 1
	end
	
	if query == "R--\n" then
		R -= 1
	end
	
	s << S[L..R]
end

p(s.size)