N, Q = map(int, input().split())
box_name = input()

field = [1] * (N+2)
for i in range(Q):
    t, d = input().split()

    for id, s in enumerate(box_name):
        if s == t:
            if d == 'L':
                field[id] += field[id+1]
            elif d == 'R':
                field[id+2] += field[id+1]
            field[id+1] = 0

print(sum(field[1:N+1]))