# -*- coding: utf-8 -*-
"""
Created on Sat Mar 30 15:26:28 2019

@author: maezawa
"""

n, q = list(map(int, input().split()))
s = input()
qs = []
for i in range(q):
    ti, di = input().split()
    qs.append([ti, di])
    
cnt = 0
i = 0
rev = 0
for c in s:
    while i<q:
        if qs[i][0] == c and qs[i][1] == 'L':
            rev -= 1
            if rev < 0:
                cnt += 1
                break
        elif qs[i][0] == c and qs[i][1] == 'R':
            rev += 1
        else:
            i += 1

i = q-1
rev = 0
for c in s:
    while i>0:
        if qs[i][0] == c and qs[i][1] == 'R':
            rev -= 1
            if rev < 0:
                cnt += 1
                break
        elif qs[i][0] == c and qs[i][1] == 'L':
            rev += 1
        else:
            i -= 1

print(n-cnt)
