_, q = map(int, input().split(" "))
field = input()
spells = [input().split() for i in range(q)]

for t, d in spells[::-1]:
    if field == "":
        break
    if field[0] == t and d == 'L':
        field = field[1:]
    if field[-1] == t and d == 'R':
        field = field[:-1]

print(len(field))