n, q = map(int, input().split())

masses = input()
mass_map = {}
for mass in masses:
    mass_map = {mass: [i + 1 for i, x in enumerate(masses) if x == mass] for mass in masses}
    
golems = [1] * (n + 2)
for i in range(q):
    mass, direction = tuple(input().split())
    if mass not in mass_map:
        continue
    indexes = mass_map[mass]
    direction = -1 if direction == 'L' else 1
    for index in indexes:
        golems[index + direction] += golems[index]
        golems[index] = 0
golems[0] = golems[-1] = 0

print(sum(golems))
