import sys

#N=マス数　Q=試行回数
N,Q = map(int,input().split())
if N > Q:
    max = N
else:
    max = Q
if 1 > max or max > 2*10^5:
    sys.exit()

#s＝マスをN個作成
s = input()
if s.islower() or len(s) != N:
    sys.exit()
    
#ｓで辞書作成
mass_list = []
mons_list = []
for mass in s:
    mass_list.append(mass)
    mons_list.append(1)
    
#Q回t,dループ
for i in range(Q):
    index_list = []
    index_num = 0
    t,d = input().split()
    if t.islower():
        sys.exit()
    if d == 'R':
        d = 1
    elif d == 'L':
        d = -1
    else:
        sys.exit()
    #対象index取得
    for mass in mass_list:
        if mass == t:
            index_list.append(index_num)
        index_num += 1
    if d == 1:
        index_list.reverse()
    #魔法発動
    for index_num in index_list:
        if mons_list[index_num] > 0:
            if 0 > index_num+d or index_num+d > N-1:
                next
            else:
                mons_list[index_num+d] += mons_list[index_num]
            mons_list[index_num] = 0
#結果表示
total = 0
for i in mons_list:
    total += i
print(total)