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

flag_left=0
flag_right=0
flag_left1=1
flag_right1=1
count_left=0
count_right=0
sum_left=[]
sum_right=[]
for i in range(q):
    if t_list[q-i-1]==s[0] and d_list[q-i-1]=="L":
        flag_left=1
        flag_left1=0
        j=1
        sum_left.append(count_left)
        count_left=1
    elif t_list[q-i-1]==s[n-1] and d_list[q-i-1]=="R":
        flag_right=1
        flag_right1=0
        k=n-2
        sum_right.append(count_right)
        count_right=1
    if flag_left1 and flag_left:
        if 0<=j<=n-1 and t_list[q-i-1]==s[j] and d_list[q-i-1]=="L":
            j=j+1
            count_left=count_left+1
        elif t_list[q-i-1]==s[j-1] and d_list[q-i-1]=="R":
            j=j-1
            count_left=count_left-1
    if flag_right1 and flag_right:
        if 0<=k<=n-1 and t_list[q-i-1]==s[k] and d_list[q-i-1]=="R":
            k=k-1
            count_right=count_right+1
        elif t_list[q-i-1]==s[k+1] and d_list[q-i-1]=="L":
            k=k+1
            count_right=count_right-1
    flag_left1=1
    flag_right1=1
sum_left.append(count_left)
sum_right.append(count_right)
print(n-(max(sum_left)+max(sum_right)))
