import math
import sys
N, Q = [int(i) for i in sys.stdin.readline().split()]
s = input()
data_ls = list()
for i in range(Q):
    t, d = [i for i in input().split()]
    data_ls.append([t,d])
t_ls, d_ls = zip(*data_ls)

def check_left(ind):
    for i in range(Q):
        if t_ls[i] == s[ind]:
            if d_ls[i] == "L":
                ind -= 1
            else:
                ind += 1
        if ind >= N:
            return False
        if ind <= -1:
            return True
    return False

def check_right(ind):
    for i in range(Q):
        if t_ls[i] == s[ind]:
            if d_ls[i] == "L":
                ind -= 1
            else:
                ind += 1
        if ind >= N:
            return True
        if ind <= -1:
            return False
    return False

last = N-1
ind = len(s) // 2
flg = 0
while True:
    if check_left(ind):
        if abs(last - ind) <= 1 and flg == 0:
            break
        elif abs(last - ind) < 1:
            ind = -1
            break
        flg = 1
        tmp = ind
        ind += math.ceil(abs(last - ind) / 2)
        last = tmp
    else:
        if abs(last - ind) <= 1 and flg == 1:
            ind -= 1
            break
        elif abs(last - ind) < 1:
            ind = -1
            break
        flg = 0
        tmp = ind
        ind -= math.ceil(abs(last - ind) / 2)
        last = tmp
    ind = min(N - 1, ind)
    ind = max(0, ind)
_sum = ind + 1

last = N-1
ind = len(s) // 2
flg = 0
while True:
    if check_right(ind):
        if abs(last - ind) <= 1 and flg == 0:
            break
        elif abs(last - ind) < 1:
            ind = N
            break
        flg = 1
        tmp = ind
        ind -= math.ceil(abs(last - ind) / 2)
        last = tmp
    else:
        if abs(last - ind) <= 1 and flg == 1:
            ind += 1
            break
        elif abs(last - ind) < 1:
            ind = N
            break
        flg = 0
        tmp = ind
        ind += math.ceil(abs(last - ind) / 2)
        last = tmp
    ind = min(N-1, ind)
    ind = max(0, ind)
_sum += N - ind
print(N - _sum)
