import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N, Q = LI()
s = input()
TD = []
T, D = [], []
for i in range(Q):
    t,d = LS()
    TD.append([t,d])


#  N, Q = 10**5, 10**5
#  s = ''.join([random.choice(string.ascii_letters) for i in range(N)])
#  TD = []
#  T, D = [], []
#  for i in range(Q):
#      if i % 2 == 0:
#          TD.append(['a','L'])
#          T.append('a')
#          D.append('L')
#      else:
#          TD.append(['b','R'])
#          T.append('b')
#          D.append('R')


# 真ん中から探す
# 幅がなくなるまでやる
lb, ub = -1, N
first_survived_left = None
previous_mid = None
while (lb + ub) // 2 != previous_mid:
    mid = (lb + ub) // 2
    original_mid = mid
    previous_mid = mid
    for td in TD:
        if td[0] == s[mid]:
            if td[1] == "L":
                mid -= 1
            else:
                mid += 1

            if mid == -1:
                lb = original_mid
                if (lb+ub)//2 == previous_mid:
                    # 左に落ちて終わりの場合
                    # 全部左に落ちない
                    print(0)
                    exit()
                break
            if mid == N:
                # 右に落ちてしまった
                ub = original_mid
                if (lb+ub)//2 == previous_mid:
                    first_survived_left = original_mid
                break
    else:
        # 落ちなかった
        ub = original_mid
        if (lb+ub)//2 == previous_mid:
            # 左に落ちずに終了
            first_survived_left = original_mid
#  print('left', first_survived_left)
if first_survived_left == N-1:
    # 誰も落ちない。
    print(N)
    exit()

lb, ub = -1, N
first_survived_right = N
previous_mid = None
while (lb + ub) // 2 != previous_mid:
    mid = (lb + ub) // 2
    #  print('-', mid)
    original_mid = mid
    previous_mid = mid
    for td in TD:
        if td[0] == s[mid]:
            if td[1] == "L":
                mid -= 1
            else:
                mid += 1
            
            if mid == -1:
                lb = original_mid
                if (lb+ub) // 2 == previous_mid:
                    first_survived_right = original_mid
                break

            if mid == N:
                ub = original_mid
                if (lb+ub)//2 == previous_mid:
                    # 右に落ちて終わりの場合
                    first_survived_right = original_mid - 1
                    print(0)
                    exit()
                break
    else:
        # 落ちなかった
        lb = original_mid
        if (lb+ub)//2 == previous_mid:
            # 右に落ちずに終了
            first_survived_right = original_mid
#  print('right', first_survived_right)

print(first_survived_right+1 - first_survived_left)
