# -*- coding: utf-8 -*-
n, q = map(int, raw_input().split())
s = [ c for c in raw_input()]

array = [1 for i in range(n)]


for i in range(q):
    t, d = map(str, raw_input().split())
    for j in range(len(s)):
        if s[j] != t: continue
        if d == 'L':
            if j != 0: array[j-1] += array[j]
            array[j] = 0
        elif d == 'R':
            if j != n-1: array[j+1] += array[j]
            array[j] = 0

print sum(array)
