import sys
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 = input()
if s.islower() or len(s) != N:
    sys.exit()
mass_list,mons_list = [mass for mass in s],[1 for hoge in range(len(s))]
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()
    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
print(sum(mons_list))