require 'set'
n, m = gets.split.map(&:to_i)
str = gets.chomp
$n = str.size + 1

size_idx = {}
l = r = 0
m.times do
	gets.chomp =~ /(\w)(.)/
	if $1 == ?R
		r += ($2 == ?+ ? +1 : -1)
	else
		l += ($2 == ?+ ? +1 : -1)
	end
	(size_idx[r - l + 1] ||= Set.new) << l
end

hash = {}
str.each_char.with_index do |c, i|
	(hash[c] ||= []) << i
end
a = []
hash.keys.sort.each_with_index do |c, k|
	is = hash[c]
	is.each {|i| a[i] = k + 1}
end
rank = [a]

d = 1
loop do
	a = (0..str.size-1).map {|i| rank[-1][i] * $n + (rank[-1][i+d] || 0)}
	hash = {}
	a.each_with_index do |x, i|
		(hash[x] ||= []) << i
	end
	a = []
	hash.keys.sort.each_with_index do |c, k|
		is = hash[c]
		is.each {|i| a[i] = k + 1}
	end
	rank << a
	d <<= 1
	break if d >= str.size
end

def compute_rank(rank, len, i)
	d = 1
	k = 0
	r = 0
	until len == 0
		if len[0] == 1
			r = r * $n + rank[k][i]
			i += d
		end
		len >>= 1
		d <<= 1
		k += 1
	end
	r
end

num = 0
size_idx.each do |len, is|
	ranks = Set.new
	is.each do |i|
		ranks << compute_rank(rank, len, i)
	end
	num += ranks.size
end
p num