num = input().split()
N = int(num[0])
Q = int(num[1])
str = input()

block = [0 for i in range(N)]
for i in range(N):
    block[i] = str[i]

call = [[0 for i in range(2)] for j in range(Q)]
for i in range(Q):
    str = input().split()
    call[i][0] = str[0]
    call[i][1] = str[1]

blockCounter = [1 for i in range(N)]
for i in range(Q):
    for j in range(N):
        if block[j] == call[i][0]:
            golemNum = blockCounter[j]
            blockCounter[j] -= golemNum
            if call[i][1] == "L" and j > 0:
                blockCounter[j - 1] += golemNum
            elif call[i][1] == "R" and j < N - 1:
                blockCounter[j + 1] += golemNum

counter = 0
for i in range(N):
    counter += blockCounter[i]
print(counter)
