import math

n, q = [int(i) for i in input().split()]
s = input()
t_list = []
d_list = []
for i in range(q):
    t, d = input().split()
    t_list.append(t)
    d_list.append(d)

num_map = {}
for i in range(len(s)):
    if s[i] in num_map:
        num_map[s[i]].append(i)
    else:
        num_map[s[i]] = [i]

def isReacheable(i):
    currentIndex = i
    for i in range(q):
        t = t_list[i]
        d = d_list[i]
        if t not in num_map:
            continue
        move_induce = num_map[t]
        if currentIndex in move_induce and d == "L":
            currentIndex -= 1
        if currentIndex in move_induce and d == "R":
            currentIndex += 1
        if currentIndex == -1:
            return True, False
        if currentIndex == n:
            return False, True
    return False, False


def bisection_method_right(start, end):
    next = math.ceil((start + end)/2)
    if next == 0 or next == n-1:
        return n-1
    reacheableRight = isReacheable(next)[1]
    neiborReachableRight = isReacheable(next+1)[1]

    if not reacheableRight and neiborReachableRight:
        return next
    if reacheableRight:
        return bisection_method_right(start, next)
    else:
        return bisection_method_right(next, end)

def bisection_method_left(start, end):
    next = math.floor((start + end)//2)
    if next == n-1 or next == 0:
        return 0
    reacheableLeft = isReacheable(next)[0]
    neiborReachableLeft = isReacheable(next-1)[0]
    if not reacheableLeft and neiborReachableLeft:
        return next
    if reacheableLeft:
        return bisection_method_left(next, end)
    else:
        return bisection_method_left(start, next)


golem_list = [1 for i in range(n)]

rightest_index = bisection_method_right(0, n-1)
leftest_index = bisection_method_left(0, n-1)

if rightest_index == leftest_index:
    if rightest_index < n/2:
        rightest_index = n-1
    else:
        leftest_index = 0

print(sum(golem_list[leftest_index:rightest_index+1]))

