n, q = map(int, input().split())
masses = input()
spells = [list(list(input().split())) for spell in range(q)]

mass_map = {}
for mass in masses:
    mass_map[mass] = [i for i, x in enumerate(masses) if x == mass]

golems = [1] * n
for spell in spells:
    if spell[0] not in mass_map:
        continue
    indexes = mass_map[spell[0]]
    for index in indexes:
        direction = spell[1]
        if direction == 'L' and index > 0:
            golems[index - 1] += golems[index]
        elif direction == 'R' and index < n - 1:
            golems[index + 1] += golems[index]
        golems[index] = 0

print(sum(golems))
