from sys import *
from numpy import ones

def magic(s,arr, t, d):
    for i in range(len(arr)):
        if s[i] == t:
            if d == 'L':
                if i != 0:
                    arr[i-1] += arr[i]
                    arr[i] = 0
                else:
                    arr[i] = 0
            else :
                try:
                    arr[i+1] += arr[i]
                    arr[i] = 0
                except:
                    arr[i] = 0
    return arr

n, q = map(int, stdin.readline().split())
s = stdin.readline()
arr = ones(len(s)-1)
for i in range(q):
    t, d = stdin.readline().split()
    arr = magic(s,arr, t, d)
print(int(sum(arr)))
