class grid:
    def __init__(self, word):
        self.word = word
        self.has_golem = 1
        self.will_move_golem = 0


def move_golem(text, dir):
    for i in range(n):
        if grids[i].word == text and grids[i].has_golem != 0:
            move_golem = grids[i].has_golem
            grids[i].has_golem = 0
            if(dir == 'L' and i != 0):
                grids[i-1].will_move_golem += move_golem
            if(dir == 'R' and i != n-1):
                grids[i+1].will_move_golem += move_golem
        else:
            continue
    for g in grids:
        g.has_golem += g.will_move_golem
        g.will_move_golem = 0

def answer():
    sum_golem = 0
    for g in grids:
        sum_golem += g.has_golem

    return sum_golem

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

grids = []
for i in range(n):
    grids.append(grid(s[i]))

for i in range(q):
    text, dir = input().split()
    move_golem(text, dir)

print(answer())
