#!venv/bin/python

import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, Q = [int(x) for x in input().split()]
S = input()
MOVE = []
for _i in range(Q):
    t, d = input().split()
    MOVE.append([t,d])

def i_will_death_at(i):
    pos = i
    for move in MOVE:
        #print("pos" + str(pos))
        ch = S[pos]
        if move[0] != ch:
            continue
        if move[1] == 'L':
            pos = pos - 1
            if pos < 0:
                return "L"
            else:
                continue
        if move[1] == 'R':
            pos = pos + 1
            if pos > N - 1:
                return "R"
            else:
                continue
    return None

first_left_death = None
first_right_death = None

search = int((N - 1)/2)
while True:
    if i_will_death_at(search) == 'L':
        if search == N - 1 or i_will_death_at(search + 1) != 'L':
            first_left_death = search
            break
        else:
            if search == N - 1:
                break
            next_search = search + int(((N - 1) - search) / 2)
            if next_search == search:
                next_search = search + 1
    else:
        if search == 0:
            break
        next_search = search - int(search / 2)
        if next_search == search:
            next_search = search - 1
    search = next_search

search = int((N - 1)/2)
while True:
    if i_will_death_at(search) == 'R':
        if search == 0 or i_will_death_at(search - 1) != 'R':
            first_right_death = search
            break
        else:
            if search == 0:
                break
            next_search = search - int(search / 2)
            if next_search == search:
                next_search = search - 1
    else:
        if search == 0:
            break
        next_search = search + int(((N - 1) - search) / 2)
        if next_search == search:
            next_search = search + 1
    search = next_search

# print (first_left_death)

ans = None
if first_left_death and first_right_death:
    ans = first_right_death - first_left_death - 1
elif first_left_death:
    ans = N - first_left_death
elif first_right_death:
    ans = first_right_death
else:
    ans = N

#print (first_left_death)
#print (first_right_death)
print(ans)
