n,q = map(int, input().split())             # 文字列カウント, 呪文数
s = input()                                 # ABC
t = [input().split() for i in range(q)]     # A L,C R,B R

golem = [1] * n

# A,L
for pos,dire in t:
    # ABC
    for i,sindex in enumerate(s):
        if dire == 'L':
            if pos == sindex:
                if i > 0:
                    golem[i-1] += golem[i]
                golem[i] = 0
        else:
            if pos == sindex:
                if i < n - 1:
                    golem[i+1] += golem[i]
                golem[i] = 0
print(sum(golem))