n, q = map(int, input().split())
s = list(input())
list =  [list(map(str, input().split())) for _ in range(q)]

monster = [1]*n

for i in range(q):
    for j in range(n):
        if s[j] == list[i][0]:
            if list[i][1] == "L":
                if j == 0:
                    monster[0] = 0
                else:
                    monster[j-1] += monster[j]
                    monster[j] = 0
            if list[i][1] == "R":
                if j == n-1:
                    monster[n-1] = 0
                else:
                    monster[j+1] += monster[j]
                    monster[j] = 0

print(sum(monster))