N, Q = list(map(int, input().split()))
s = list(input())

s_dict = dict([(c, []) for c in s])
for i, c in enumerate(s):
    s_dict[c].append(i)

golems = dict([(i, 1) for i in range(len(s))])
spells = []
for i in range(Q):
    spell = input().split()
    spells.append(spell)

for spell in spells:
    if spell[0] not in s:
        continue
    pos = s_dict[spell[0]]
    schedule = [0 for i in range(len(golems))]
    for p in pos:
        num = golems[p]
        schedule[p] -= num
        if spell[1] == 'L':
            if p == 0:
                continue
            schedule[p - 1] += num
        else:
            if p == len(s) - 1:
                continue
            schedule[p + 1] += num
    for i, diff in enumerate(schedule):
        golems[i] += diff
    # print(golems)

total = 0
for golem in golems.values():
    total += golem
print(total)
