#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, Q = [int(x) for x in input().split()]
S = input()
D = defaultdict(dict)
for i in range(len(S)):
    s = S[i]
    D[s][i] = 1

MOVE = []
for _i in range(Q):
    t, d = input().split()
    MOVE.append([t,d])

#print (MOVE)
#print (D)

for move in MOVE:
    #print(D)
    #print ("move: "+ str(move))
    t, d = move
    key = list(D[t].keys())
    for i in key:
        if d == 'L':
            if i == 0:
                D[t].pop(i)
            else:
                if i - 1 in D[S[i - 1]]:
                    D[S[i - 1]][i - 1] += D[t].pop(i)
                else:
                    D[S[i - 1]][i - 1] = D[t].pop(i)
        if d == 'R':
            if i == N - 1:
                D[t].pop(i)
            else:
                if i + 1 in D[S[i + 1]]:
                    D[S[i + 1]][i + 1] += D[t].pop(i)
                else:
                    D[S[i + 1]][i + 1] = D[t].pop(i)

num = 0
for s in D:
    for i in D[s]:
        num += D[s][i]

print(num)
