n, q = [int(i) for i in input().split()]
addresses = input()

golems = [1] * n
for i in range(q):
    t, d = input().split()
    i = 0
    for address in addresses:
        if t == address:
            if d == 'R':
                if i != n - 1:
                    golems[i + 1] += golems[i]
                golems[i] = 0
            else:
                if i != 0:
                    golems[i - 1] += golems[i]
                golems[i] = 0
        i += 1


print(sum(golems))
