INF = 1 << 28
N, q = gets.split.map(&:to_i)
S = gets

def move(pos, op)
  S[pos] != op[0] ? pos : (op[2] == ?L ? pos - 1 : pos + 1)
end

l,r = [0, N - 1]

$<.reverse_each do |op|
  l = (l - 1 .. l + 1).min_by{|pos| move(pos, op) >= l ? pos :  INF}
  r = (r - 1 .. r + 1).max_by{|pos| move(pos, op) <= r ? pos : -INF}
  break if r < l
end
puts r < l ? 0 : r - l + 1
