# coding: utf-8
# Your code here!

i = input().split()

n = int(i[0])
q = int(i[1])

i = input().split()

mass = list(i[0])
# print(mass)

golem_num_list = [1] * len(mass)

# print(n, q)

cast_list = []
for item in range(q):
    cast_list.append(input())

left = int(len(golem_num_list) / 2) - 1
# print(left)
right = left + 1
# print(right)

# check: center to right 
for item in range(right, len(mass)):
    # print("チェックするインデックス", item)
    
    fall_index = None
    r_index = item
    for loop in range(q):
        # print("チェックする文字", mass[r_index])

        cast = cast_list[loop].split()
        # print("cast:", cast[0])
        # print("move:", cast[1])
        
        if mass[r_index] == cast[0]:
            if cast[1] == 'R':
                r_index += 1
            else:
                r_index -= 1
                                    
        # print("r_index:", r_index)

        if r_index >= len(mass) or r_index < 0:
            # print("落ちる")
            fall_index = item
            break

    if fall_index is not None:
        # print("終わり")
        break

if fall_index is not None:    
    for item in range(fall_index, len(golem_num_list)):
        golem_num_list[item] = 0
        # print("潰す index ", item)

# print("---")

# check: center to 0 
for item in reversed(range(0, left + 1)):
    # print("チェックするインデックス", item)
    
    fall_index = None
    l_index = item
    for loop in range(q):
        # print("チェックする文字", mass[l_index])

        cast = cast_list[loop].split()
        # print("cast:", cast[0])
        # print("move:", cast[1])
        
        if mass[l_index] == cast[0]:
            if cast[1] == 'L':
                l_index -= 1
            else:
                l_index += 1
                                    
        # print("l_index:", l_index)

        if l_index >= len(mass) or l_index < 0:
            # print("落ちる")
            fall_index = item
            break

    if fall_index is not None:
        # print("終わり")
        break

if fall_index is not None:    
    for item in range(0, fall_index + 1):
        golem_num_list[item] = 0
        # print("潰す index ", item)

sum = 0
for item in range(len(golem_num_list)):
    sum += int(golem_num_list[item])
    
print(sum)

